add folder name to filename

Nikolaos A. Patsopoulos npatsop@cc.uoi.gr
Thu Sep 14 12:23:00 GMT 2006


Hi,

I have
the following structure of folders and files:

..
folder1
         file1
         file2
folder2
         file1
         file2
.....

and want to add the folder name into the filename:


folder1
         folder1_file1
         folder1_file2
folder2
         folder2_file1
         folder2_file2

I used the following script but doesn't work under cygwin:

for file in folder*/*; do
      dir=$(basename $(dirname $file) )
      base=$(basename $file)
      mv $file $(dirname $file)/${dir}_${base}
done

Does anyone has a suggestion or where I should look?


Thanks in advance,

Nikos




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list