help with search and copy script

realmjumper99

Registered
I have a number of files sprawled out over multiple directories on my one external drive (I use it to back up multiple machines I work on here at work)
I want to gather all of those files into one folder (/collection) so that I can go through them all and come up with one consistent naming and filing system.
The workflow of the script should go as follows:
1. Recursively search for all files of type "log"
2. Each time it finds a file it puts the file name and path into a variable (%C)
3. if the file already exists in /collection, rename it by putting the letter z at the end
4. copy the file into /collection

I know how to do some of it
1. find -type log /drive of folders not containing /collection
2.
3.
4. cp %C /collection/%C

Can any help me out with figuring out the missing pieces or does someone have a better way of doing this?
 
You may want to check out the Mac OS X application "Big Mean Folder Machine", which can both split files from a single directory into multiple directories, or assimilate multiple files from various locations into a single location based upon a set of criterium.
 
I have been playing with this all weekend and i came up with this bit of script

>find ../boomstick \*.log\*
followed by
>filenew=$file
>while [ e /newdir/$filenew ]; do
> $filenew=z+$filenew
>done
>cp $path/$file /newdir/$filenew

but how do i get $file and $path from the find command?
 
Look into the -exec option of the find command. You can have it execute certain scripts on every file it finds.
 
Back
Top