Computing.Net > Forums > Programming > Robocopy function in a batch file

Robocopy function in a batch file

Reply to Message Icon

Original Message
Name: IPITGuy
Date: August 11, 2005 at 09:49:16 Pacific
Subject: Robocopy function in a batch file
OS: Win XP
CPU/Ram: 2.3 GHz 1GB RAM
Comment:

Hey all.

I'm trying to write a batch file, but I'm in the process of self-teaching the commands, so I'm wondering if someone can tell me whether or not what I want to do is possible before I give myself a headache.

I want to tell the batch to look in a particular text file for a list of files to be copied and then use robocopy to /mir those files onto an external hard drive.

Will a batch recognize the MS resource kit robocopy command, especially when referring the source from lines in a .txt file?

Basically what I'm looking to do is copy (and preserve metadata in) a specific list of files that would be written in a .txt file. We're using this to create a "pristine" copy of only files we want on a specific drive before shipping it back from whence it came.

Am I overcomplicating things by trying to use robocopy to preserve the date/time created data, etc? Is this as simple as I hope it will be or is an amateur batch file writer just going to botch this up?

I don't want the batch file written for me, I'm just hoping for a direction to point myself in.

thanks for your time.



Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: August 11, 2005 at 23:03:50 Pacific
Subject: Robocopy function in a batch file
Reply: (edit)

Hi CJ,

I never heard of robocopy, but if it preserves time & date it's worth knowing about.

Psuedo code:

for /f every line in a txt file do robocopy.

HTH

M2
If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: IPITGuy
Date: August 15, 2005 at 07:17:43 Pacific
Subject: Robocopy function in a batch file
Reply: (edit)

So I've pretty much gotten everything working in my batch file as described above, but I think I'm making an amateur mistake. Unfortunately, our "batch pros" here at the office either can't or won't help me figure out what I'm doing wrong and I'm hoping someone would be kind enough to provide a little guidance.

For every source line I pull from my .txt file, I can get robocopy to recognize the line as the source path, BUT when it gets to the file name at the end (i.e. C:\My Documents\Pictures\test.jpg) it still considers the test.jpg as part of the folder name and can't find a file to copy. When it lists the source, it shows, using my example:

c:\My Documents\Pictures\test.jpg\

Then says it can't find a file to copy to the source is invalid.

Everything else is coming out right -it's just that one little thing. I'm wondering if this is because I'm using quotes around the source lines in the .txt file, but I don't know of any other way to get the batch to recognize that spaces in source folder names are all part of the same source.

Is there a command to get the batch file to ignore white space in folder names? I can't alter the folder names from the source because that data needs to remain pristine (the reason I'm using robocopy as well, we want as close to the original as possible).


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: August 16, 2005 at 00:16:42 Pacific
Subject: Robocopy function in a batch file
Reply: (edit)

It may be that robocopy only takes paths, not file names. If so, you're shovelling against the tide.

Try:

robocopy /?


M2


If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 4
Name: IPITGuy
Date: August 16, 2005 at 06:13:34 Pacific
Subject: Robocopy function in a batch file
Reply: (edit)

Good call, you're right. The simplest things always seem to escape me. But hey, I wouldn't be working in this firm if I didn't enjoy shoveling against the tide.

I'm going to place the file name on a separate line and call it into the robocopy command separately. Whee.

Thanks for the logic-minded assist!


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Robocopy function in a batch file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software