Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DOS: Moving file to a location with similar folder structure

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

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 57

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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 57

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
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…

722 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