mohona
asked on
Shell script for renaming files
Dear experts,
Please help me creating a bash/ksh shell script which will rename all .txt and .TXT files to .csv file in a particular directory and with in it's sub directories.
Thanks in advance.
Please help me creating a bash/ksh shell script which will rename all .txt and .TXT files to .csv file in a particular directory and with in it's sub directories.
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you have Python, you can use the script here.
eg usage:
eg usage:
# ls -1
test.txt
test1.TXT
# filerenamer.py -p ".txt" -e ".csv" -l -I "tes*.*"
==>>>> [ /home/test.txt ]==>[ /home/test.csv ]
==>>>> [ /home/test1.TXT ]==>[ /home/test1.csv ]
# filerenamer.py -p ".txt" -e ".csv" -I "tes*.*" #remove -l to commit
/home/test.txt is renamed to /home/test.csv
/home/test1.TXT is renamed to /home/test1.csv
# ls -1
test.csv
test1.csv
ASKER
Thank you all.
find /dir -name "*.txt' -o -name "*.TXT" | while read file
do
nfile=`echo $file | sed 's/\....$//'`
mv $file $nfile.csv
done