-1

This question already has an answer here:

I have a folder containing 500 files like this:

 xaa
 xab
 xac
 xad
 aae
 aaf

I want to add ".txt" to the end of all of them to get something like this:

xaa.txt
xab.txt
xac.txt
xad.txt

How would this be done?

marked as duplicate by Stephen Rauch, steve, Romeo Ninov, don_crissti, Jeff Schaller Jul 19 '17 at 0:52

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.

  • There may be a duplicate Q out there, but the currently-linked one doesn't have answers for this question. – Jeff Schaller Jul 18 '17 at 20:21
1

With simple find + mv command:

find yourfolder/ -type f -exec mv {} {}".txt" \;
  • yes, works .... – Anna1364 Jul 18 '17 at 17:20
0

There are several ways. Here are three:

rename 's/$/.txt/' ???    # Might be prename on some systems

for f in ???; do mv "$f" "$f.txt"; done

find -maxdepth 1 -type f -exec mv {} '{}.txt' \;

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