-1

I want to add the ".sbd" after all files ending on ".utf8" in a directory I do not want to replace the extensions, but really want to add them so the filenames will look like "filename.utf8.sbd" I think I should adapt the following code, but don't manage to find out exactly how

for f in *.utf8 ; do mv "$f" "$f.sbd" ; done

Can anyone help me? I am very new to the command line Thanks a bunch!

  • Possible duplicate of [How do I rename the extension for a batch of files?](https://stackoverflow.com/q/1224766/608639), [Changing extension to multiple files](https://unix.stackexchange.com/q/19654/56041), [Recursively change file extensions in Bash](https://stackoverflow.com/q/21985492/608639), etc. – jww Jul 24 '18 at 14:42

1 Answers1

1

Your code should work if no file has spaces (or other "special" character) in the name and if the directory is not pathologically big.

In those cases, you can use something like this:

ls|grep '*.utf8$'|while read i; do mv "$i" "$i.sbd"; done
SimoneLazzaris
  • 329
  • 2
  • 9