I have this script that I’m running to rename all the files in a folder to “1.png”, “2.png”, etc, but sometimes it will completely erase (or move the file somewhere else, I have no idea what’s happening) the first 10 or so images. This seems to happen whenever there’s more than 10 images inside the folder. The script I’m running is below, anyone have any ideas?
#!/bin/bash
cd "$1"
cnt=1
for fname in *
do
if [ "$1" != '/var/www/cydia.stumpyinc.com/theme/images/browse/icons/' ]
then
mv "$fname" ${cnt}.png
cnt=$(( $cnt + 1 ))
fi
done
EDIT
I’m also getting this error in the terminal, don’t know if it’s important or not though
mv: cannot stat `*': No such file or directory
Your script is bizarre: from your description the correct way of renaming everything to a number should be something like: