Friday, May 16, 2008

cmd wildcards

I always thought that this would work under Windows:
> touch f1.txt f2.txt f3.txt
> ren f*.txt gg*.txt
However it fails miserably:
C:\projects\test\test1>touch f1.txt f2.txt f3.txt

C:\projects\test\test1>ren f*.txt gg*.txt
A duplicate file name exists, or the file cannot be found.
A duplicate file name exists, or the file cannot be found.

C:\projects\test\test1>dir
Volume in drive C has no label.
Volume Serial Number is 7563-3993

Directory of C:\projects\test\test1

05/16/2008 08:42 PM <DIR> .
05/16/2008 08:42 PM <DIR> ..
05/16/2008 08:42 PM 0 f2.txt
05/16/2008 08:42 PM 0 f3.txt
05/16/2008 08:42 PM 0 gg.txt

3 File(s) 0 bytes
2 Dir(s) 159,707,815,936 bytes free

C:\projects\test\test1>
A ("somewhat" complicated) solution is presented here.