I have tons of image inside a folder and it also has different file types. I have tried googling for an answer but I can't seem to find one. I wanted the files to be named 1.jpg, 2.png, 3.gif. . . n.JPEG. Could someone help me out with this?
1 Answer
Try the command below:
cd path_to_your_files
declare -i i=0; for f in *; do i=$((i+1));fn=$i".${f##*.}"; mv "$f" "$fn"; done
Make note that the command above is a bash script.
7 Comments
Francis Salvamante
Should the path be a string? It gives me an error
mv: cannot stat ‘/home/vianney/Downloads/Image Processing/Images/*’: No such file or directoryNguyen Sy Thanh Son
I edited my command. And are you sure that your OS is using BASH as in the default?
Nguyen Sy Thanh Son
Check default shell by:
echo $SHELLFrancis Salvamante
result of
echo $SHELL == /bin/bashNguyen Sy Thanh Son
show me the output of command:
for f in path_to_your_files/*; do echo "$f", done; |
man rename(which is a perl tool, maybe you have to install perl).perlexpmean?