bankadmin
asked on
need some assitance with xcopy command
I want to create a bat file that will copy files from one directory to another but I ran into a question I dont know the answer to. I need to move a single file from directory A to directory B everyday. A new file is created in directory A every day (the directory will continually build 1 file a day) but when the file is moved to directory B it is moved by an automated process to another directory. So on day two we now have 2 files in directory A and zero files in directory B but I only want to copy the new file from directory A not both files because the first file came across on day one and was processed. How can I set it up so it will not copy the same file twice even though the file doesnt exist in directory B any longer?
I would like to use a simple xcopy bat file for this if possible and set it up as a scheduled task..
I would like to use a simple xcopy bat file for this if possible and set it up as a scheduled task..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THanks for the help I will split the points. We had some confusion with what was happening and as it turns out the files can be removed from from director A so a simple move command will work for us.. Again thanks for the help
It sounds like you are including the files too, with robocopy you specify directories, not file specs, and then the file spec afterwards:
robocopy "C:\dir1 \sub dir" "c:\dest dir\sub dir" *.*
If you check the error level when copying note that Upto 7 is "good", 8 onwards generally not. There is list of the error codes around if wanted - the codes below 8 mean such things as "file copied", "extra file in destination" etc.
Steve
robocopy "C:\dir1 \sub dir" "c:\dest dir\sub dir" *.*
If you check the error level when copying note that Upto 7 is "good", 8 onwards generally not. There is list of the error codes around if wanted - the codes below 8 mean such things as "file copied", "extra file in destination" etc.
Steve
ASKER
I've requested that this question be closed as follows:
Accepted answer: 250 points for serialband's comment #a39728108
Assisted answer: 250 points for dragon-it's comment #a39728224
Assisted answer: 0 points for bankadmin's comment #a39729503
for the following reason:
THe original question became a none issue
Accepted answer: 250 points for serialband's comment #a39728108
Assisted answer: 250 points for dragon-it's comment #a39728224
Assisted answer: 0 points for bankadmin's comment #a39729503
for the following reason:
THe original question became a none issue
dragon-it beat me to it. Glad you solved your problem.
As dragon-it mentioned, robocopy.exe only takes directories as it parameters. It's mainly used as a "poor man's" backup tool, since it can mirror entire directories and keep time stamps, ownership and permissions settings. xcopy doesn't. I very rarely use xcopy anymore.
As dragon-it mentioned, robocopy.exe only takes directories as it parameters. It's mainly used as a "poor man's" backup tool, since it can mirror entire directories and keep time stamps, ownership and permissions settings. xcopy doesn't. I very rarely use xcopy anymore.
ASKER
robocopy.exe "F:\dir\dir 1\dir 2\*.*"
Do you know why this is getting errors?
There are spaces in the directory names so I quoted the path