I have a folder with a bunch of png image files. I need to trim the filenames to remove some information from the end.
E.g.
some file-170227-222746.png
some other file-170228-222742.png
another file-170226-222743.png
I need to remove everything after the - while retaining the .png extension, to end up with:
some file.png
some other file.png
another file.png
All files are png image files and I don't need to keep the original files.
I've tried this which works but does the wrong thing, in that it removes the .png extension
for file in *.png; do
mv -- "$file" "$(file%%.png"
done
Can the above mv command be reworked to do what I need? Should I use a different method?
Thanks
-and the.pngat the end (not simply "everything after the-"), yes?