Can someone help me with a perl file to rename some files please? I can do it with regular command line using the below code, but I need to include this in another script and the other script is perl. I know nothing of perl.
for file in C*
do
newfilename=`echo $file | cut -c8-21-`
mv $file $newfilename
done
If you're doing this in an existing script I'm assuming you'll need to glob the files (angle braces in the code) rather than using @ARGV.
The second substr can also be expressed as a negative offset (substr($_,-10)), which would allow a variable center part - if say you happen to run into a 'ABCDEFG20090904024156a.00565.txt'.