Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
The Parent Dir is having around 400 Child Dirs. and each Child Dir having many files. I need to move all the files from all the Child Dirs to the Parent Dir at once.
Any help, will be appreciated much.
Prakash

Here is a simple batch script
save the text in any text editor as a .bat format under all files type, preferred wordpad or notepad.include the " marks, they are required if the path has any spaces in, most likely will.
REMEMBER, ZIP THE CHILD DIRECTORY IN A ZIP FILE
@echo off
xcopy "path to child dir.zip" "path to parent dir"
Pause>nulEXAMPLE
@echo off
xcopy "C:\Child.zip" "C:\Parent"
Pause>nul

Dear RobJohnB95,
Thanks for your reply.
i'm having the scenario like,
D:\Documents --- parent folder
and it has around 400 Child folders
D:\Documents\f123\
D:\Documents\f653\
D:\Documents\f8972\
D:\Documents\f912\so, i need to move the files from all the child folder to Parent folder.
Can you please help me in this?
Thanks in advance,
Prakash

This will work if you are just trying to move files from a subfolder to the parent directory, it won't move files from within a subfolder of the subfolder, give a test and see if it will work for you. Save it as a .VBS and change the Origin folder.
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "c:\test"
For Each Folder in oFSO.GetFolder(sOriginFolder).subfolders
For Each sFile In oFSO.GetFolder(Folder).Files
oFSO.MoveFile sfile, sOriginFolder & "\" & sFile.Name
next
next

Or you can do it in a batch file that will copy everything including files in subfolders of subfolders using a batch file like the following, again all you have to change is the path of the originfolder
@Echo off
Set sOriginFolder="c:\test"For /f "Tokens=*" %%a in ('Dir %sOriginFolder% /a-d /s /b') do (
move "%%a" %sOriginFolder%
)

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |