Removing leading "./" in file paths
I am writing a script to compare the existence of files in <source> directory with <dest> directory, and if so the size of each. Passed experience has told me that a bash shell buffer cannot hold all the names of files. (there are more than 102,000 files).
Luckily we use a strict folder structure for 3 levels: Client/Project/Stage. (After this the folder names are not consistent.)
So I wrote a script as follows:
sourcepath=$'/Volumes/SOURCE/ProjectWork'
destpath=$'/Volumes/DEST/ProjectWork'
logfile='~/Desktop/file_compare.txt'
for client in $(find $sourcepath -type d -depth 1 ! -name '.DS_Store'); do
for proj in $(find $client -type d -depth 1 ! -name '.DS_Store'); do
for stage in $(find $proj -type d -depth 1 ! -name '.DS_Store'); do
for f in $(find . -type f ! -name '.*'); do
# check file exists in destination folder
done
done
done
done
Problem is the $f variable contains a "./" at the front, which I need to strip off before checking exists in destination folder, otherwise folder cannot be found, i.e. /Volumes/DEST/Projects/Client/Project/Stage/./Folder/Filename
Any ideas how to handle this or improve upon it please? (I only really know how to dabble with bash and use of sed or awk were not successful.)
Thanks in advance.
Cheers
C.
MacBook Pro 15" 2.16GHz Intel Core 2 Duo, Mac OS X (10.5)