I'm trying to remove what I "think" is a bad character. How I got the bad character is when I downloaded jpgs onto my PC and then renamed the files using windows explorer. In cygwin, the files look like
The unquoted whitespace in the filename is interpreted by the shell as a field separator. mv sees more than two arguments and expects the last one to be a directory.
Assuming you have files with this format only. Here script is adding 2 more zeros at the number in the bracket
for file in *
do
new_file_name=$(echo "$file" | sed -e 's/\\ //g' -e 's/([0-9]*/&00/g' )
mv "$file" "$new_file_name"
done
Hope this helps:)
One more -
Assuming you have two directories one is input and second destination. And assuming you have image names like 1,2,3,.... so on..
#Count gives you latest digit/number of a image you have...
Count=$(ls /Dest_dir/* | awk -F "[()]" '{ print $2}' | sort | tail -1)
ls /input_dir/* | while read line
do
let Count+=1 #Increment the counter
new_file_nanme=$(echo "$file" | sed -e 's/\\ //g' -e 's/([0-9]*)/('"$Count"')/g')
mv "$file" "$new_file_nanme"
done