Reputation: 9783
I have this command in my windows's script (.cmd file):
CALL mv *.exe foo.exe
The wildcard character doesn't seem to be be interpreted as a wildcard at all, because the when the script is executed, it throws an error about not finding a file with name *.exe
(literally *.exe). There is a .exe file in the current directory, by the way.
So how should I rewrite this command? Thanks
Upvotes: 6
Views: 10042
Reputation: 15968
In windows, you don't need to use 'call' unless calling another batch script. You also probably want to use the 'move' command instead; this will interpolate the * correctly in windows.
For example, if you use a script that has:
move *.exe foo.exe
in it, you get an outcome like this:
C:\dev\example>dir /B
a.exe
mymove.cmd
C:\dev\example>mymove
C:\dev\example>move *.exe foo.exe
C:\dev\example\a.exe
1 file(s) moved.
C:\dev\example>dir /B
foo.exe
mymove.cmd
C:\dev\example>
Giving exactly the behavior you're looking for!
Upvotes: 2
Reputation: 21507
If mv
is available, maybe you have sh.exe
or bash.exe
nearby. Then it's easy:
sh.exe -c "mv *.exe foo.exe"
CMD interpreter doesn't expand wildcards, unlike unix shells: commands do (or don't do) it by themselves. Maybe builtin ren
command will expand wildcard, but I'm unsure.
Upvotes: 2