3

In Bash I can move a directory without know the full directory name like so:

mv gradle-*/ gradle/

How do I do this in cmd (i.e. batch file, not powershell).

The move command doesn't seem to allow this.

jscott
  • 24,484
  • 8
  • 79
  • 100
vicsz
  • 133
  • 1
  • 5

1 Answers1

5

MOVE only moves 1 dir to another location and therefore doesn't bother expanding wildcards. Unlike Unix where the shell expands wildcards on Windows each command has to do it by itself which leads to all sorts of differing behaviour between commands.

You can use the FOR command to simulate this.

FOR in it's various variants behaves somewhat like "find . -name "wildcard" -exec {} " on Unix.

FOR /d %%i IN (gradle-*) DO move %%i gradle\%%i
Tonny
  • 6,332
  • 1
  • 18
  • 31
  • Works! Thx .. I had to remove the last %%i in your example – vicsz Mar 29 '12 at 21:35
  • Wasn't to sure about it myself if that would be correct syntax. But I didn't have a Windows box in the vicinity to test at the time so I had to go from memory. – Tonny Mar 31 '12 at 19:52