简体   繁体   中英

Bash - renaming multiple file extensions

I've just very recently switched to Linux and I want to change a load of files to have different extensions. For example I want to change .doc/docx to .txt and images to .jpg and so on. Is there a csh script that would cover any extension or would I have to write a new one for each filetype.

I have this so far, but I'm not sure if it will actually work. Any help is much appreciated!

#!/bin/bash
for f in *.$1
do
    [ -f "$f" ] && mv -v "$f" "${f%$1}$2"
done

无需重新发明轮子: http//linux.die.net/man/1/rename

rename .doc .txt *.doc

You need proper programs to convert file format:

That would do the rename; keep in mind that renaming a Word document won't cause it to become text, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM