开发者

How to remove part of filename and add extension programmatically?

开发者 https://www.devze.com 2022-12-18 03:26 出处:网络
I have hundreds of files in one folder named like this: index.html?tab=This is - the file 开发者_高级运维name

I have hundreds of files in one folder named like this:

index.html?tab=This is - the file 开发者_高级运维name

I would like to remove "index.html?tab=" part and add extension ".txt" to all files. How can I do this using Unix command line tools (I'm using MacOSX 10.6.2)?


In bash,

for i in index.html\?tab\=*; do mv "$i" "${i:15}.txt"; done


for file in index.html\?*
do
   mv "$file" "${file#*=}".txt
done
0

精彩评论

暂无评论...
验证码 换一张
取 消