Shell script to restructure folders recursively
Hello all,
I need some help. I have to copy hundred of files from the following structure:
office/desk/file1.txt
office/desk/file2.txt
office/chair/file1.txt
office/chair/file2.txt
office/chair/file3.txt
to this structure:
office_desk1/file1.txt
office_desk2/file2.txt
office_chair1/file1.txt
office_chair2/file2.txt
office_chair3/file3.txt
I'm not good at writing shell script. The closes script that I found so far is this:
function copy_files() {
echo copying $1 files
tar -cf - `find . -name "*.$1" -print` | ( cd ../dest && tar xBf - )
}
I don't know how to create a folder from the folder it's in and the file number.
|