Need a small help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
waldo13x
Posts: 3
Joined: 30 Jan 2014 08:16

Need a small help

#1 Post by waldo13x » 30 Jan 2014 08:38

I have no experience at all with writing any batch files or anything but looking to create one to do automatic backups for certain files from one host to a shared drive. So if anyone can help me create this script I would really appreciate it.

So what I need is a script that will run a batch file on a local computer that is on a network that will copy a folder from its C:\ called "GDATA" and then will paste this file on a shared drive called \\hstn16\color$\Color Computer Backup

The only catch is that it needs to create a new folder in the desired location with the name of that computer it is copying the file from and then paste it withing that directory.


For example if the computer name is "abcd"

So GDATA folder needs to go from Computer "abcd" C:\GDATA to \\hstn16\color$\Color Computer Backup\abcd\GDATA <------ this abcd folder needs to be created within the script though. Also there needs to be a command if there is already an "abcd" folder created in \\hstn16\color$\Color Computer Backup then it just needs to just paste it within that folder that was created before.

Hope this makes sense and it is possible. Thanks.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need a small help

#2 Post by foxidrive » 30 Jan 2014 09:36

Code: Select all

@echo off
xcopy "C:\GDATA\*.*"  "\\hstn16\color$\Color Computer Backup\%computername%\GDATA\"

waldo13x
Posts: 3
Joined: 30 Jan 2014 08:16

Re: Need a small help

#3 Post by waldo13x » 30 Jan 2014 09:39

Will this create that folder with the computer name ....if it does not see it in that directory?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need a small help

#4 Post by foxidrive » 30 Jan 2014 10:01

Yes, xcopy will create the path, and just copy if it already exists.

waldo13x
Posts: 3
Joined: 30 Jan 2014 08:16

Re: Need a small help

#5 Post by waldo13x » 30 Jan 2014 10:03

Awesome Thanks

Post Reply