File search and rename

October 22, 2010 at 04:43:04
Specs: Windows XP
I'm searching through ~100 folders and their subfolders for a specific file. I want to copy all instances of that file to another directory. Unfortunately, all instances have the same name, so I'd like to rename each file with something... anything unique. I tried the following:

find D:/drive -name *FILE -maxdepth 5 -exec cp -v {} D:/drive/collect/FILE`date +%s` \;

This does a great job of finding and copying the files; unfortuantely, it is to fast for the date +%s to be useful.

Any suggestions? Thank you!

See More: File search and rename

Report •

October 22, 2010 at 18:07:05
Since you are using Unix tools under Windows XP, you must be using something like the Cygwin package. If you are, you probably have a shell. If so, consider using a script that copies each file object found and sleeps for a second or two between copies:

find D:/drive -name *FILE -maxdepth 5 -print|while read filename
  cp -v $filename D:/drive/collect/FILE`date +%s`
  sleep 2

Report •
Related Solutions

Ask Question