Computing.Net > Forums > Windows Server 2008 > Move files from many child dir to parent dir

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Move files from many child dir to parent dir

Reply to Message Icon

Name: suryaprakasan
Date: October 21, 2009 at 03:10:47 Pacific
OS: Windows 7
Product: Microsoft Windows server 2008 standard
Subcategory: General
Tags: move, Windows
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: RobJohnB95
Date: October 21, 2009 at 09:13:01 Pacific
Reply:

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>nul

EXAMPLE

@echo off
xcopy "C:\Child.zip" "C:\Parent"
Pause>nul


-1

Response Number 2
Name: suryaprakasan
Date: October 21, 2009 at 20:28:04 Pacific
Reply:

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


1

Response Number 3
Name: gtaion
Date: November 11, 2009 at 05:45:22 Pacific
Reply:

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


1

Response Number 4
Name: gtaion
Date: November 11, 2009 at 06:03:30 Pacific
Reply:

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%
)


1

Response Number 5
Name: suryaprakasan
Date: November 11, 2009 at 21:05:38 Pacific
Reply:

Dear gtaion,

Its a great help. It works fine for me.

Thanks a lot.

Prakash


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Move files from many child dir to parent dir

Upgrade from Server 08 SP1 to R2? www.computing.net/answers/windows-2008/upgrade-from-server-08-sp1-to-r2/126.html

migrate users www.computing.net/answers/windows-2008/migrate-users/33.html

Roaming profil windows server 2008 www.computing.net/answers/windows-2008/roaming-profil-windows-server-2008-/34.html