Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DOS: Moving file to a location with similar folder structure

Posted on 2013-01-29
7
Medium Priority
?
640 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 59

Accepted Solution

by:
Bill Prew earned 1500 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 59

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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 59

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 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