Why doesn't this script work?
- by Devin
I've been using this bash script:
for i in $(ls); do mv $i a$i; done
to prepend all filenames in a folder with the letter a. I'm afraid that at some point I'll accidentally use this script in the wrong directory and prepend a ton of filenames that I don't want prepended. So I decided to explicitly cite the path to the file. So now my script looks like this:
for i in $(ls /cygdrive/c/Users/path/to/Images); do mv /cygdrive/c/Users/path/to/Images/$i /cygdrive/c/Users/path/to/Images/a$i; done
It does prepend the filename with the letter a, but it also appends the filename with this ? symbol.
Any ideas why it would do that?
If it helps any, I'm using cygwin on a Windows 7 box.
Thanks for the help!