Solved

DOS: Moving file to a location with similar folder structure

Posted on 2013-01-29
7
628 Views
Last Modified: 2013-02-06
I have the following folder struture

C:\Folder 1
  - Subfolder A
  - Subfolder B
  - Subfolder C

Each subfolder has several files within it.  I would like a dos command to move all files across all subfolders to their appropriate subfolder within the following destination location:

C:\Folder 2
  - Subfolder A
  - Subfolder B
  - Subfolder C

For example, a file with the following path "C:\Folder 1\Subfolder B\File.txt" will get moved to "C:\Folder 2\Subfolder B\File.txt" .

Any help is appreciated.
0
Comment
Question by:badabing1
  • 4
  • 3
7 Comments
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 38831193
Sure, XCOPY can do this quite well for you.  Use the /E option to preserve the folder structure, so something like this:

xcopy "C:\Folder 1" "C:\Folder 2" /E /I

Then, if you really want to "move" rather than "copy", after you verify the copy did what you wanted you can delete the source with:

rd /s /q "C:\Folder 1"

If you really have to do it all with one single command, then ROBOCOPY may be the easiest way there, like:

robocopy "C:\Folder 1" "C:\Folder 2" /S /MOVE

~bp
0
 

Author Comment

by:badabing1
ID: 38831288
Thanks for your response bp.
As these files are quite large I would prefer a move as I suspect this would be far quicker than a copy.  This is important as another process is going to pull these files elsewhere and I do not want it half way through a copy when this happens.  

Also I am using RoboFTP's DOSCMD function to do this job.  I do not believe I can run the robocopy command from RoboFTP, is that correct?
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 38831328
I haven't used RoboFTP, so I would say give the ROBOCOPY approach a test and see if it works.

~bp
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 53

Expert Comment

by:Bill Prew
ID: 38831343
Taking a quick look at the online help for RoboFTP, you probably need to use the EXEC command to run ROBOCOPY.

~bp
0
 

Assisted Solution

by:badabing1
badabing1 earned 0 total points
ID: 38843058
Thanks for the help bp.

I have used RoboFTP to do the move.  I could not get it to work using the EXEC command:
EXEC "rotoftp.exe c:/folder1 c:/folder2 /MOV /S"

Open in new window

I did however get it to work by adding the above code into a batch file and then calling that batch file through the DOSCMD command within roboftp.
0
 

Author Comment

by:badabing1
ID: 38843089
Closed
0
 

Author Closing Comment

by:badabing1
ID: 38858675
The final solution implemented.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question