[Hampshire] Shell help - copying files

Top Page

Reply to this message
Author: Rob Malpass
Date:  
To: Hampshire LUG Discussion List
Subject: [Hampshire] Shell help - copying files
Hi all

I need a bit of help with some shell scripting please:

1) I need the syntax to recursively copy all files from a tree to one single directory so if I have

/a/x.mp3
/a/y.mp3
/b/p.mp3

then what I want is a.mp3, b.mp3 and p.mp3 to be in one folder - wherever I decide to put it e.g. ~/allmp3s. Any files with the same filename can be ignored - not overwritten. I know it's going to be something to do with cp -R but the rest is foxing me.

2) Much more complicated (probably) I need then to take my one folder with 6000 mp3s in it and compare it to another folder which has basically the same files differently organised i.e. into different directories. I.e. I want it to search the new structure for a.mp3 and only copy it into the new structure if it can prove it's not there already. To be honest, I'd settle for a list of files that are not in the new structure.

A little more about the problem follows for those that are interested [suspect this will turn into a bit of a rant so apologies in advance]... I moved from an IRiver 20Gb mp3 player to an 80Gb ipod about 18 months ago. Now one problem with ipods is that you're largely forced to use apple's itunes. Once I'd learned it, no great problems - but Itunes has a nasty little intermittant fault - for no apparent reason - it loses yes loses a handful of your mp3s. You click on one and you get an exclamation mark saying the file's not there any more. If I'd shifted or renamed the file then fine - but it's done it to me with podcasts which itunes itself takes full care of - I never know where the files are.

So now before I chuck my old Iriver away (battery life is minimal now) I'd like to ensure that itunes hasn't lost any files. Here's where it gets complicated. With the Irivier - files were accessed as if it were just another drive - i.e. drag and drop so for example a playlist e.g. all songs beginning with a was just a case of

mkdir songsa
mv a*.mp3 songsa/

Itunes as most will know has a much flatter structure. Underneath the root is one folder per artist, then below that is each album for the artist, then at the 3rd level is the actual mp3s.

Last thought - if any of you know a workaround for "the dreaded itunes exclamation mark" I'd love to hear it. Part of the problem comes because I keep my itunes library on a NAS. Mostly so I can get at it from over the network and partly because a) I do most access from XP and XP has a habit of needing periodic reinstall wiping everything on the local drive which is where the itunes library is normally and b) [can you believe this?] the only method of backing up your itunes library that I can find from within itunes itself is multiple DVDs!!!!! I have around 22Gb of music and that's not a lot nowadays but that would still be around 5+ DVDs Quite ridiculous IMHO.

Rant over - any help with the shell stuff very much appreciated

TIA

Rob