View Full Version : Quick and Dirty file backup command
Trekkie
Oct 31, 2004, 01:46 PM
I'd like to have a command either in the terminal or the applescript or whatever that would do the following:
Copy all iTunes Music Store Files from my Music folder & it's subdirectories and put them in a specific directory with the heirearchy intact ignoring the copy if files there exist and haven't changed.
I thought I could accomplish this with the CP command and have tried various forms of
cp -r /sourcedir/*.m4p /destdir -r and get *.m4p not found
Any suggestions?
musicpyrite
Oct 31, 2004, 02:17 PM
I'm not at my Mac right now to test this, but I'll throw out a guess.
Your searching for files that are .m4p when you have .mp3 or something other.
I know that when I open the 'iTunes Music' folder, I am presented with multiple folders that a labeled by the artist's name, so the cp command doesn't know to look in those sub directories, only the 'iTunes Music' folder.
wrldwzrd89
Oct 31, 2004, 02:55 PM
I'd like to have a command either in the terminal or the applescript or whatever that would do the following:
Copy all iTunes Music Store Files from my Music folder & it's subdirectories and put them in a specific directory with the heirearchy intact ignoring the copy if files there exist and haven't changed.
I thought I could accomplish this with the CP command and have tried various forms of
cp -r /sourcedir/*.m4p /destdir -r and get *.m4p not found
Any suggestions?
First of all, you don't need the *.m4p or the second -r.
cp -r /sourcedir /destdir
That command will copy everything, regardless of whether it exists or has changed. There's a utility called psync (http://www.bombich.com/software/files/psync.dmg) which is just what you're looking for. Here's a manual (http://search.cpan.org/dist/MacOSX-File/bin/psync) for psync.
Trekkie
Oct 31, 2004, 03:31 PM
First of all, you don't need the *.m4p or the second -r.
cp -r /sourcedir /destdir
Actually, I do need the *.m4p because I don't want to copy the 30GB or so of *.mpa because I already have my ripped CD collection in Apple Lossless backed up somewhere. These are my compressed for my iPod collection that I don't want/need backed up
gekko513
Oct 31, 2004, 03:50 PM
Here's one solution. Assuming you want backup of all .m4p files in the iTunes folder and that you wish to put your music in a directory named ~/iTunesBackup (the ~ will automatically expand to your home-directory)
cd ~/Music
This changes directory to the Music directory.
find iTunes -type d -exec mkdir ~/iTunesBackup/{} \;
This will ensure that the same directory hierarchy in the backup-folder exists as in the iTunes folder.
find iTunes -regex .*m4p -exec cp -n {} ~/iTunesBackup/{} \;
This will copy all files which name ends in m4p into the ~/iTunesBackup folder. Yes .*m4p is correct, because it is a regex and the .* means the same thing as * does in normal shell patterns. The -n option will make it skip files that already exist. You can put this procedure in a bash script to make it easier. Create a file (named backupMusic.sh) with the following content:
#!/bin/bash
cd ~/Music
find iTunes -type d -exec mkdir ~/iTunesBackup/{} \;
find iTunes -regex .*m4p -exec cp -n {} ~/iTunesBackup/{} \;
Save it and then run:
chmod a+x backupMusic.sh
This makes the script executable. To run the script, just type:
./backupMusic.sh
reckless_0001
Nov 3, 2004, 02:58 PM
I believe you mean...
*.mp4 = aac files
and not
*.m4p = nothing
wrldwzrd89
Nov 4, 2004, 04:22 AM
I believe you mean...
*.mp4 = aac files
and not
*.m4p = nothing
Nope, not quite...
*.m4a = aac files OR apple lossless files
*.m4p = protected aac files
*.mp4 = mpeg-4 video files
reckless_0001
Nov 4, 2004, 08:41 AM
Nope, not quite...
*.m4a = aac files OR apple lossless files
*.m4p = protected aac files
*.mp4 = mpeg-4 video files
LOL that's funny I knew the .m4a and I still got that wrong.. I wonder what world I was in.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.