Hi ,
Need help to rename the files in a folder. The .xml needs to be removed from the middle and appended to the end as in the example shown .
Example From:
TestMessage.xml2010-10-19_20_21_08
TestMessage.xml2010-10-20_20_21_09
TestMessage.xml2010-10-21_20_21_08
TestMessage.xml2010-10-22_20_21_09
Example To:
TestMessage2010-10-19_20_21_08.xml
TestMessage2010-10-20_20_21_09.xml
TestMessage2010-10-21_20_21_08.xml
TestMessage2010-10-22_20_21_09.xml
Thanks in advance.
Chari
clx
2
If you are sure you have only files you want to rename;
ls * | awk -F ".xml" '{print "mv "$0,$1$2".xml"}' | sh
Please check first without the RED, if every thing seems file, go with that.
with sed,
echo "TestMessage.xml2010-10-19_20_21_08" | sed 's/\(.*\)\.xml\(.*\)/\1\2\.xml/g'
1 Like
Another one:
ls | while read file
do
new=$(echo "file"|sed 's/\([^\.]\)\(\....\)\(.*\)/\1\3\2/')
mv "$file" "$new"
done
alister
4
for f in *; do
mv "$f" "${f%%.xml*}${f#*.xml}.xml"
done
Regards,
Alister
ls -1|nawk -F".xml" '{print $1$2".xml"}'