Why doesn't this script work?

Posted by Devin on Super User See other posts from Super User or by Devin
Published on 2012-10-01T20:02:03Z Indexed on 2012/10/01 21:41 UTC
Read the original article Hit count: 278

Filed under:
|
|

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!

© Super User or respective owner

Related posts about windows-7

Related posts about cygwin