Experts Exchange connects you with the people and services you need so you can get back to work.
REM Define base or root directory to work in
REM Loop through all first level folders in base folder1
for /D %%A in ("%BaseDir%\*") do (
REM Loop through each subfolder to the first level folders
for /D %%B in ("%%A\*") do (
REM Move all files from the second level to the first level
move "%%B\*.*" "%%A"
REM Try to remove this second level folder now
Open in new window
Be seen. Boost your question’s priority for more expert views and faster solutions
sBaseFolder = "c:\temp\base"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oBaseFolder = oFSO.GetFolder(sBaseFolder)
For Each oSubFolder In oBaseFolder.SubFolders
For Each oSubSubFolder In oSubFolder.SubFolders
oFSO.MoveFile oSubSubFolder & "\*.*", oSubFolder & "\"
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $389.00.
Premium members get this course for $95.20.
Premium members get this course for $159.20.
Premium members get this course for $168.80.
Premium members get this course for $62.50.