Linux novice here.
I'm building my very first bash script and I've written code to truncate and clean up csv file names however its very static and I have to manually count characters I wish to truncate. I'd like to dynamically remove the prefix of files. I've seen numerous examples where folks keep the prefix but I effectively, want to keep the last 7 chars (or more....including file extension.)
Sample below.
# Sample of filenames in a folder
SOLO_PAL3.xyz.ino.IVC.csv -> renamed to IVC.csv
SOLO_PAL3.xyz.ino.EVC.csv -> renamed to EVC.csv
SOLO_PAL3.xyz.ino.VVC.csv -> renamed to VVC.csv
SOLO_PAL3.xyz.ino.WVC.csv -> renamed to WVC.csv
Filename Truncation - while this works, cut -c19- requires manual updating for the integer for specific file lengths at present. I left echo on in this example so I can see the change before I execute.
for file in ???*;
do echo mv $file `echo $file | cut -c19-`;
# Something equivalent to RIGHT($file,$file.length-($file.length)-7))?
done
Many thanks in advance!