Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wild card (asterisk) in Windows batch

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

like image 769
user1508893 Avatar asked Oct 06 '22 11:10

user1508893


1 Answers

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.

like image 107
Anton Kovalenko Avatar answered Oct 10 '22 03:10

Anton Kovalenko