Solved

DOS: Moving file to a location with similar folder structure

Posted on 2013-01-29
7
635 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 56

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 56

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 56

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

617 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