-1

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?

Stephen Rauch
  • 4,209
  • 14
  • 22
  • 32
Anna1364
  • 1,006
  • 1
  • 17
  • 33

2 Answers2

2

With simple find + mv command:

find yourfolder/ -type f -exec mv {} {}".txt" \;
RomanPerekhrest
  • 29,703
  • 3
  • 43
  • 67
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' \;
roaima
  • 107,089
  • 14
  • 139
  • 261