0

I have a folder with ~30 files. The are already BitTorrent metafiles that lack a .torrent suffix. I want to change all those files to .torrent files. How would I do that? In windows it was as easy as typing

ren *.* *.torrent

while being inside the folder with all those files.

I am not sure what the current file extension of those 30 files is.

Appreciate any help!

3 Answers3

1

If you can install rename:

sudo apt install rename

Try:

rename 's/\.[a-zA-Z0-9]{1,}$/.torrent/' *.*

On another note, remember changing file extension won't change its file type or contents.

Abhishek Nair
  • 574
  • 3
  • 9
  • Thank you so much for the quick response! I thought I would change the file type when I rename the files...

    Sorry I'm still really new to Linux and was used to that from Windows.

    What do I have to do to actually change the files to .torrent files?

    Thanks again!

    – mjmike mike Aug 04 '19 at 19:57
  • What type of files are these that you are renaming as ".torrent"? Can you give more details into it. Thanks. – Abhishek Nair Aug 05 '19 at 00:38
1
for file in *; do
  base=`echo "${file%.*}"`
  mv -- "${file}" "${base}.torrent"
done

Worked for me!

0
sudo apt install krusader krename

Krusader has a menu for File-MultiRename on selected files in it's browser, which browser also can be filtered . krename can also be used in terminal and it's own gui when run without parameters.

pierrely
  • 653