[英]Rename all the files in the folder with increasing numbers
我有一個文件夾,在該文件夾中我有10-15個文件,任意名稱。 文件名可以包含空格。 例如: wWw.page.com __ (576)_002
。 在終端中,當我按w
然后tab
,文件名顯示如下: wWw.page.com\\ \\ __\\ \\(576\\)_0.txt
。
我想要一些腳本,將重命名我的所有文件,如0.txt
, 1.txt
, 2.txt
等。
我的問題是: wWw.page.com __ (576)_002.txt file not found
。
index=0;
for i in $(ls *.txt)
do
cp "${i}" $index".txt"
done
而不是ls
嘗試glob
:
index=0;
for name in *.txt
do
cp "${name}" "${index}.txt"
index=$((index+1))
done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.