1

I have say 30000 files of this type: picture.jpg.~12~

They are remnants of a backup (mv -v --backup=numbered ...).

I needed to switch the extensions to: picture.~12~.jpg

xerostomus
  • 990
  • 9
  • 20

1 Answers1

1

I have found this solution finally which might inspire you in This Long Dark Covid-time of the Soul.

ls *~*~* | sed -n "s/\(.*\)\.\([^.]*\).\(~[0-9]*~\)$/mv  -v --backup=numbered  \"\0\" \"\1_\3.\2\"/p" >switch_extensions.sh
chmod +x switch_extensions.sh
./switch_extensions.sh > switch_extensions.log

The first line produces commands:

mv  -v --backup=numbered  "Trombone.tif.~10~" "Trombone_~10~.tif"

The second line makes it executable, the third is renaming while creating a log file. Then swiftly comes relief from the dark soul ruminations. Try it!

You might know a smarter solution, so let brains storm! :-)

xerostomus
  • 990
  • 9
  • 20