Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I'm looking for windows command or batch script to help me, i Spent 3h reading/ trying to find a solution i know its out there but my lack of scripting/programming isn't helping, hoping some can help me out.

I have a set of folders and files that i would like to bring up to the 2nd level subfolder which in this example would be subfolder1 & subfolder1 & subfolder3 etc.




share|improve this question
up vote 0 down vote accepted

Your goal is risky - what happens if the same file name exists in multiple subdirectoies? Only one version can exist in a given folder.

The following command prompt one liner will move files as you requested, and duplicate names will overwrite already existing files with that name:

for /d %A in ("d:\folder\*") do @(pushd "%A"&(for /r /d %B in (*) do @move /y "%B\*" "%A" 2>nul)&popd)

Or, as a batch script:

@echo off
for /d %A in ("d:\folder\*") do (
  pushd "%A"
  for /r /d %B in (*) do move /y "%B\*" "%A" 2>nul
share|improve this answer
Perfect!. it works just as intended. the files are unique so no overwriting will happen. Thank you very much. i wish superuser/stackexchange had built it "buy coffee" feature to show appreciation with more than just words. Thanks again. – user2827759 Oct 17 '13 at 4:46

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.