Quote:
Originally Posted by andou
I tried this with a test directory of 17 Randomly named files. The result was sh: test: too many arguments 13 times and sh: test: Photo: binary operator expected 2 times. However, 2 of the files came out as expected: FILE002 and FILE003.
Sidenote: This is with .jpg files. I changed "FILE%03i" to "FILE%03i.jpg", so the two files came out: FILE002.jpg and FILE003.jpg. None of the other file names changed.
|
I think you have spaces in your filenames, which my script didn't handle. It's simple to fix by putting double-quotes around filenames....
Code:
c=0
for i in *.jpg
do
test -f "$i" &&\
mv "$i" $(printf "FILE%03i.jpg" $c) &&\
((c+=1))
done