Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

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
share|improve this answer
Works! Thx .. I had to remove the last %%i in your example – vicjugador 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.