[QUOTE=omnio]
Code:
else
echo $FILE is renamed to $(dirname $FILE)/$1_$(basename $FILE)
mv $FILE $(dirname $FILE)/$1_$(basename $FILE)
fi
done
hi omnio
can u explain me the above two lines ...
I didnt come across dirname and basename till now....
What mistake is there in my approach...
Code:
else
echo $FILE is renamed to ${1}_${FILE}
mv $FILE ${1}_${FILE}
fi
Please let me know the mistake in my code .......!!!
Sorry to say that script is not working ...
I have tried with the new code but its showing cannot rename
the file just under test directory is renamed...
but the files in the subdirectories are not getting renamed...
I tried using both ...i.e ./test and test as the command line arguments.....
[linux@localhost bash_script.tar.gz_FILES]$ ./rename ./test
./test is a directory
./test/1/f is renamed to ./test/1/./test/1_f
mv: cannot move `./test/1/f' to `./test/1/./test/1_f': No such file or directory
./test is a directory
./test/2/f is renamed to ./test/2/./test/2_f
mv: cannot move `./test/2/f' to `./test/2/./test/2_f': No such file or directory
./test/file is renamed to ./test/./test_file
[linux@localhost bash_script.tar.gz_FILES]$ ./rename test
test is a directory
test/1/f is renamed to test/1/test/1_f
mv: cannot move `test/1/f' to `test/1/test/1_f': No such file or directory
test is a directory
test/2/f is renamed to test/2/test/2_f
mv: cannot move `test/2/f' to `test/2/test/2_f': No such file or directory
test/file is renamed to test/test_fil
bye