tag:blogger.com,1999:blog-256954733201794633.post6285202551567778851..comments2023-05-23T14:31:59.559+01:00Comments on Munky Morgy: Using Xargs on Mac TerminalUnknownnoreply@blogger.comBlogger14125tag:blogger.com,1999:blog-256954733201794633.post-2609302397800112682018-04-06T22:12:42.891+01:002018-04-06T22:12:42.891+01:00thanks
thanks<br />Anonymoushttps://www.blogger.com/profile/03568736208113798767noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-64965690803582733962018-01-20T15:11:09.446+00:002018-01-20T15:11:09.446+00:00I've got a question about the syntax of mac xa...I've got a question about the syntax of mac xargs. I was reading through the tutorials here ...<br />https://ryanstutorials.net/linuxtutorial/bonus.php#xargs<br />and came across this command for xargs ...<br /><br />basename -s .JPG -a *.JPG | xargs -n1 -i mv {}.JPG {}.jpg<br /><br />to change the case of extensions. It works just fine on linux but the syntax is slightly different for mac. Playing around with it and thanks to this post I was able to modify the command to work on mac, here it is ...<br /><br />basename -s .JPG -a *.JPG | xargs -n1 -I {} mv {}".JPG" {}".jpg"<br /><br />I understand the difference b/w -i and -I (though don't really understand the reasoning behind the change) but why the extra {}, what is the purpose? As far as I see it, the first part of the command, gets the basename of all files (ex: image.JPG, image2.JPG, image3.JPG) with a .JPG extension, passes that into the xargs command and replaces the {} with "image". So in the first, linux, command it would go something like this mv image.JPG image.jpg; image2.JPG image2.jpg; image3.JPG image3.jpg. But the second one seems to do as such image.JPG mv image.JPG image.jpg ... and so on. Which doesn't make any sense. Help me understand it please.147https://www.blogger.com/profile/06561254455079322620noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-17214352856132506662017-06-06T14:39:30.070+01:002017-06-06T14:39:30.070+01:00For files with embedded spaces:
If you quote the ...For files with embedded spaces:<br /><br />If you quote the placeholder, it should work. E.g. for a file name "a file.txt" (no quotes), the following changes it to "afile.txt" (again, no quotes): ls *file.txt | xargs -I '{}' mv '{}' afile.txt<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-54045901765232217502017-04-29T10:59:54.363+01:002017-04-29T10:59:54.363+01:00it does not work when the file name contains space...it does not work when the file name contains space.李洋https://www.blogger.com/profile/09070802731309453214noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-50767550543259224132017-04-29T10:58:58.764+01:002017-04-29T10:58:58.764+01:00This comment has been removed by the author.李洋https://www.blogger.com/profile/09070802731309453214noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-56244707348010557472016-12-07T22:11:06.364+00:002016-12-07T22:11:06.364+00:00Fantastic. Exactly what I needed to copy just the ...Fantastic. Exactly what I needed to copy just the PDF files from a whole slew of subdirectories into another one on my Mac. Thanks much.Johnhttps://www.blogger.com/profile/01918006683836461575noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-11967232949547930382016-10-21T11:21:09.307+01:002016-10-21T11:21:09.307+01:00Really great news!!! this information is well wort...Really great news!!! this information is well worth looking everyone. Good tips. I will be sharing this with all of my friends! Thank you for sharing valuable information.<br />__________________________<br /><a href="http://mybrushes-app.com/drawing-tool/Top-10-Photo-Graphic-Design-Software-for-Mac.html" rel="nofollow">Graphic Design Software for Mac</a>Anonymoushttps://www.blogger.com/profile/16902053854345998249noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-37941351789791803342015-01-18T18:43:18.787+00:002015-01-18T18:43:18.787+00:00Yep, your post did it for me too. I references it ...Yep, your post did it for me too. I references it on <a href="" rel="nofollow">stack overflow</a>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-46320366647308873692014-02-19T17:34:49.135+00:002014-02-19T17:34:49.135+00:00thanksthanksAlihttps://www.blogger.com/profile/06005392729045072397noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-49673027116756602452013-02-27T22:38:28.768+00:002013-02-27T22:38:28.768+00:00If you are using MacPorts, just use gxargs.If you are using MacPorts, just use gxargs.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-43734538411556889862012-06-03T10:58:13.924+01:002012-06-03T10:58:13.924+01:00Proviso:
$ ls *fla | xargs -I {} mv {} {}"c&...Proviso:<br /><br />$ ls *fla | xargs -I {} mv {} {}"c"<br /><br />xargs has a problem here with filenames beginning with a space or containing an apostrophe - watch out for French filenames containing things like "qu'a".wdefnoreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-66714185324844160102012-06-03T10:33:47.744+01:002012-06-03T10:33:47.744+01:00Excellent tip, thanks. This provides undoubtedly ...Excellent tip, thanks. This provides undoubtedly the easiest way to batch rename files whose filenames contain spaces:<br /><br />Eg The following will change the extension of files in the current directory from .fla to .flac<br /><br />$ ls *fla | xargs -I {} mv {} {}"c"<br /><br />Brilliant!wdefnoreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-90265467755261941132010-04-21T20:55:45.027+01:002010-04-21T20:55:45.027+01:00Thank you, am glad I could help.
I like macs but t...Thank you, am glad I could help.<br />I like macs but they do have some stupid parts, like non gnu defaults.<br /><br />Poor WinTels.A Personhttps://www.blogger.com/profile/15781187907805266734noreply@blogger.comtag:blogger.com,1999:blog-256954733201794633.post-71517581920925723272010-04-21T19:45:40.169+01:002010-04-21T19:45:40.169+01:00Thank you, good Lord, Thank You.
Days of searchin...Thank you, good Lord, Thank You.<br /><br />Days of searching produced constant frustration with<br />find . | xargs cp (or mv) {} <br />and a nearly infinite permutation of same.<br /><br />Doesn't Bleedin' Work On The Stupid Mac.<br /><br />Your site is the Only Place I found the key.<br /><br />Which Works. Caloo, Callay . . .<br /><br />Stupid Mac.<br /><br />And yes, I own a few Macs. <br />And some WinTels, which sit ignored in their little cases.<br />Poor little WinTels.<br /><br />Stupid Macs.<br /><br />Thank you. <br />Yes, again.Anonymousnoreply@blogger.com