This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

add folder name to filename


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]