Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Trekkie

macrumors 6502a
Original poster
Nov 13, 2002
921
29
Wake Forest, NC
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?
 
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.
 
Trekkie said:
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 which is just what you're looking for. Here's a manual for psync.
 
wrldwzrd89 said:
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
 
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 said:
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
 
wrldwzrd89 said:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.