Thursday, 25 March 2010

Rsync files based on extension

Using the includes / excludes with rsync always gives me a headache. The best that I can say is that it's confusing, but when you finally get it to work, it works well. But that's the hard part.

Yesterday I was trying to sync all files that have a given extension (*.mp3 or *.m4a) from a slow external drive to local to figure out which ones should I need to import into iTunes (can't import them all since that would create duplicates).

I found a helpful post that show that you can use the unix tool find and then have rsync use those files. Very, very helpful since I'm much more comfortable using find than rsync.

Here's my solution for sync'ing mp3's or m4a files from a mounted shared drive to a subdirectory (called "music") from where the command is being run.

find /Volumes/Shared/ -name *.mp3 -o -name *.m4a | rsync -av --files-from=- / music

No comments:

Post a Comment