Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'odd filenames' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
odd filenames
Authored by: mervTormel on Jul 03, '02 02:53:29AM

another problem with the cp `find results` is that it will gak on filenames with spaces or otherwise chars out of the normal char range ( [A-z][0-9] _ ). special chars in the filename need to be quoted to be passed to cp without poison.

see the forums thread link in the hint above for chicanery that will make the results more better.



[ Reply to This | # ]
odd filenames
Authored by: clith on Jul 04, '02 01:57:47PM
Normally you would use "xargs" together with "find" to handle strange, space-filled names. However, the version of xargs shipped with MacOS X is vastly underpowered compared to the Linux [GNU] version. In the Linux version I could write:
% find . -name '*.jpg' -print0 | xargs -0 -t -i mv '{}' /path/to/new/folder
but the MacOS X version does not have the "-i" flag that lets you use '{}' as a token to represent the filename, so you would have to use perl (since there is no way to move the destination dir to the end of the "mv" command using xargs):
find . -name '*.jpg' -print0 \\ | perl -0 -ne 'push @files, $_; END { print "mv \\"", join("\\" \\"", @files), "\\" /path/to/new/folder\\n"; }'
Now that just prints out a nice big "mv" command for you and you can copy-and-paste your way to happiness. Anything further is left as an excercise for the reader. :-)

[ Reply to This | # ]