簡體   English   中英

使用不斷增加的數字重命名文件夾中的所有文件

[英]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.txt1.txt2.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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM