0

I have many files with different extensions in one directory (for example .aa, .1ab, .412 . etc). How can I change extensions of all this files to .txt There is now other files in folder, only those I want to change extensions.

Thank You.

marked as duplicate by Videonauth, Jacob Vlijm, Mark Kirby, Pilot6, muru command-line May 30 '16 at 5:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Why change the extension? You can open simple text files with Mousepad, Leafpad or other Notepad-like app directly, no matter what the extension may be. – ipse lute May 29 '16 at 13:58
2
for IF in *.* ; do OF="${IF%.*}.txt" ; mv -n $IF $OF ; done
  • I'd suggest adding a -n or --no-clobber to the mv command just in case any names conflict after changing the suffix – steeldriver May 29 '16 at 15:10
  • Edited. Also, mv will complain about both source and destination files are identical. I don't know how to avoid this except maybe redirecting STDERR to /dev/null. – NuMessiah May 29 '16 at 15:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.