gpt4 book ai didi

linux - Bash - 重命名多个文件扩展名

转载 作者:IT王子 更新时间:2023-10-29 00:52:22 26 4
gpt4 key购买 nike

我最近刚切换到 Linux,我想更改大量文件以具有不同的扩展名。例如,我想将 .doc/docx 更改为 .txt,将图像更改为 .jpg 等等。是否有一个 csh 脚本可以涵盖任何扩展名,或者我是否必须为每种文件类型编写一个新脚本。

目前我已经有了这个,但我不确定它是否真的有效。非常感谢任何帮助!

#!/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

关于linux - Bash - 重命名多个文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10150105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com