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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Robocopy function in a batch file

Reply to Message Icon

Name: IPITGuy
Date: August 11, 2005 at 09:49:16 Pacific
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.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 11, 2005 at 23:03:50 Pacific
Reply:

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.


0

Response Number 2
Name: IPITGuy
Date: August 15, 2005 at 07:17:43 Pacific
Reply:

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).


0

Response Number 3
Name: Mechanix2Go
Date: August 16, 2005 at 00:16:42 Pacific
Reply:

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.


0

Response Number 4
Name: IPITGuy
Date: August 16, 2005 at 06:13:34 Pacific
Reply:

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!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Robocopy function in a batch file

Extract comp. alias in a batch file www.computing.net/answers/programming/extract-comp-alias-in-a-batch-file/11253.html

Get a Folder size in a batch file www.computing.net/answers/programming/get-a-folder-size-in-a-batch-file/9587.html

Putting Sound in a batch file www.computing.net/answers/programming/putting-sound-in-a-batch-file/15461.html