Quick and Dirty file backup command

Discussion in 'Mac OS X 10.3 (Panther) Discussion' started by Trekkie, Oct 31, 2004.

  1. Trekkie macrumors 6502a

    Trekkie

    Joined:
    Nov 13, 2002
    Location:
    Wake Forest, NC
    #1
    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?
     
  2. musicpyrite macrumors 68000

    musicpyrite

    Joined:
    Jan 6, 2004
    Location:
    Cape Cod
    #2
    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.
     
  3. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #3
    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.
     
  4. Trekkie thread starter macrumors 6502a

    Trekkie

    Joined:
    Nov 13, 2002
    Location:
    Wake Forest, NC
    #4
    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
     
  5. gekko513 macrumors 603

    gekko513

    Joined:
    Oct 16, 2003
    #5
    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
     
  6. reckless_0001 macrumors 6502

    Joined:
    Sep 22, 2003
    Location:
    Canada
    #6
    I believe you mean...

    *.mp4 = aac files
    and not
    *.m4p = nothing
     
  7. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #7
    Nope, not quite...

    *.m4a = aac files OR apple lossless files
    *.m4p = protected aac files
    *.mp4 = mpeg-4 video files
     
  8. reckless_0001 macrumors 6502

    Joined:
    Sep 22, 2003
    Location:
    Canada
    #8

    LOL that's funny I knew the .m4a and I still got that wrong.. I wonder what world I was in.
     

Share This Page