-1

I have multiple files all named

seperate1
seperate2

etc. How do I rename them all to have the extension .csv?

Braiam
  • 35,380
  • 25
  • 108
  • 167
Teddy77
  • 2,883
  • 7
  • 23
  • 34

1 Answers1

1

If there are only files which shall be renamed:

for file in *; do
  mv "$file" "${file}.csv"
done

If there are files with a dot which must be excluded:

for file in *; do
  [[ $file == *.* ]] && continue
  mv "$file" "${file}.csv"
done

Or with shopt -s extglob:

for file in +([^.]); do
  mv "$file" "${file}.csv"
done
Hauke Laging
  • 88,146
  • 18
  • 125
  • 174