1.

Solve : Changing Directory Structure / Moving Folders and Files?

Answer»

I am looking for direction in writing a batch file that will move data from 1 directory structure to ANOTHER on a 2003 server.

I did this the first time over the weekend to move approximately 376 GB of data, and I have to do this again for another department in the near future. We are now seeing that some files are missing, while others are not, and we lost about 65 GB that we cannot ACCOUNT for. Thank gawd for backups!

We used the xcopy / delete method as follows:

xcopy e:\Department\SubDept1\%1 e:\Department\Jobs\%1\SubDept1 /e
rmdir e:\Department\SubDept1\%1 /s /q

xcopy e:\Department\SubDept2\%1 e:\Department\Jobs\%1\SubDept2 /e
rmdir e:\Department\SubDept2\%1 /s /q

xcopy e:\Department\SubDept3\%1 e:\Department\Jobs\%1\SubDept3 /e
rmdir e:\Department\SubDept3\%1 /s /q

...and so on.

Is there anyway I can include error checking? I've now added the "tree (dir) /f /a > text.txt" command to write out file names and folder structures both before and after I run the batch so I can visually confirm after the fact, but I would like something that can warn me of an error before it deletes folders and files.

Also, I will be renaming all the Job\%1 folders based on job numbers (ie. 203, 204, 205, ETC.) -- can I make a .txt file containing this job list and run a loop so that it will parse through the numbers from top to bottom?

I've looked for a couple days now and I can't seem to come up with the right solution for either scenario.

Any help on this is greatly appreciated.Hmm... Maybe try to compare the copied files to the original ones using the fc command.

Like this (/A /B /C are only sample commands) :
------------------------------------------------------------------------------------------------------------------------------------------
fc /A /B /C DRIVE1:\First file DRIVE2:\Secondfile
fc /A /B /C DRIVE1:\First file DRIVE2:\Secondfile

I haven't used the 'fc' command for a while so if this doesn't help much go into cmd and type fc /?
Hope this helps! Your original method is not very safe for the data being copied. It seems like it would be very easy to lose files with the copy, then delete without any error checking as you mentioned.

I would personally try ROBOCOPY which is a Microsoft tool that is a free download available in the Windows Server 2003 RESOURCE Kit Tools (http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en). With Robocopy, you could use a command like:
Code: [Select]robocopy "e:\Department\SubDept1\%1" "e:\Department\Jobs\%1\SubDept1" /E /MOVE
robocopy "e:\Department\SubDept2\%1" "e:\Department\Jobs\%1\SubDept2" /E /MOVE
robocopy "e:\Department\SubDept3\%1" "e:\Department\Jobs\%1\SubDept3" /E /MOVE
If for some reason a file was not copied correctly, it would still exist in the source, and robocopy would also give you a report at the end telling you how many files (if any) failed.



Discussion

No Comment Found