I have a folder and inside that folder I have 10-15 files with arbitrary names.
The filenames may include spaces in them. For example: wWw.page.com __ (576)_002
.
In a terminal, when I press w
and then tab
the file name appears like this: wWw.page.com\ \ __\ \(576\)_0.txt
.
I want some script that will rename all my files like this 0.txt
, 1.txt
, 2.txt
and so on.
My problem is: wWw.page.com __ (576)_002.txt file not found
.
index=0;
for i in $(ls *.txt)
do
cp "${i}" $index".txt"
done
Another is to simultaneously press the Ctrl + A keys. Right click on the first file/folder and select Rename. Type in the name you want to use and press Enter. All the files/folders will now have the same name but with sequential numbers.
Use the File Explorer to navigate to the folder where your files are. Select all the files you want to rename, then right-click them and choose See more options in the context menu. Then, choose PowerRename in the second context menu. You'll now see the PowerRename interface with all your selected files.
To rename multiple files from File Explorer, select all the files you wish to rename, then press the F2 key. The name of the last file will become highlighted. Type the new name you wish to give to every file, then press Enter.
You can batch rename images in Windows by selecting (Shift+click or Ctrl+click to select several files; Ctrl+A to select all) and pressing right-click > "Rename".
Instead of ls
try to glob
:
index=0;
for name in *.txt
do
cp "${name}" "${index}.txt"
index=$((index+1))
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With