Find files and move them

Hi there,
currently looking for a UNIX command (I will later on trigger it from Applescript ) that searches a specified folder (and it's sub-folders) and moves all files of a certain file type, i.e .mp3 files into another directory.

Any help greatly appreciated...

iBook G4, Mac OS X (10.4.11), 1.2 GHz

Posted on Mar 15, 2009 9:45 AM

Reply
9 replies

Mar 15, 2009 6:16 PM in response to Mark Jalbert

First of all thanks to Eric,Tony,Mark and Nils for resolving this question so quickly. All of your Solutions were helpfull and have worked, even though compiling the scripts in applescript was a small hazzle that required a few tricks to fool the syntax.
For the intended use of this script I only need to handle relatively small data size (< 500 mb) so speed has not been the issue. Since Marks solution seemed to include the handling of filenames with spaces in the filenames, which happens with mp3s on a regular basis, I went with his choice.
The line took about 1 second to execute and did exactly as intended.
Thanks again.

Enjoy,
me

Mar 16, 2009 4:30 PM in response to mju:sick

Since Marks solution seemed to include the handling of filenames with spaces in the filenames, which happens with mp3s on a regular basis, I went with his choice.


find specifiedfolder -iname "*.mp3" -exec /bin/mv {} anotherdirectory \;
will also handle spaces in filenames.

However, Mark's solution of using xargs is more efficient.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Find files and move them

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.