You are not logged in.

#1 26 Nov 2009 12:10

James Hurrell
Member
Registered: 26 Nov 2009
Posts: 2

ROBOCOPY: strange error

I have developed a ROBOCOPY script to automatically move out files over 30 days old from a network share (this share holds PDF scans produced by a network scanner, which inevitably gets clogged up with junk), put them in another folder and then delete that folder. Here is the script, which I launch from a batch file:

REM Moves any files and sub-folders over 30 days old to D:\cleanup\dump. Retries ten times. Logs transfers to "move.log" file.
"C:\Program Files\Windows Resource Kits\Tools\robocopy" D:\Scans D:\cleanup\dump\ /E /MOVE /MINAGE:30 /R:10 > D:\cleanup\logs\move.log

REM Removes the folder D:\cleanup\dump and all its contents.
rd /Q /S D:\cleanup\dump

This works OK, but I always get the following error in the log file during the ROBOCOPY part of the script:

009/11/25 15:05:59 ERROR 32 (0x00000020) Deleting Source Directory D:\Scans\
The process cannot access the file because it is being used by another process.

Why is it trying to remove the SOURCE folder?

I have this identical script running on another machine where the source folder contains a white space, so the source is enclosed with quote marks as follows:

"D:\Scans A"

On this machine, I never get the above error...

Any idea what is going on and why this error is occuring?

Thanks

Offline

#2 26 Nov 2009 14:11

insthink
Member
Registered: 24 Oct 2009
Posts: 51

Re: ROBOCOPY: strange error

James Hurrell wrote:
 D:\Scans D:\cleanup\dump\ /E /MOVE
009/11/25 15:05:59 ERROR 32 (0x00000020) Deleting Source Directory D:\Scans\
The process cannot access the file because it is being used by another process.

Why is it trying to remove the SOURCE folder?

/MOVE : Move files and dirs (delete from source after copying).

Taken from http://ss64.com/nt/robocopy.html



you should specify that you're moving files and not folders.

D:\Scans\*.* D:\cleanup\dump\ /E /S /MOVE

or better yet

D:\Scans\ D:\cleanup\dump\ /E /S /MOV

Last edited by insthink (26 Nov 2009 14:16)

Offline

#3 26 Nov 2009 15:37

James Hurrell
Member
Registered: 26 Nov 2009
Posts: 2

Re: ROBOCOPY: strange error

Thanks for your response. I'm also trying to move any extraneous folders that may get created in there, as well as files...

D:\Scans\*.* D:\cleanup\dump\ /E /S /MOVE >> Does not work - ERROR : Invalid Parameter #1 : "D:\Scans\*.*"

D:\Scans\ D:\cleanup\dump\ /E /S /MOV >> Works... many thanks!
--

Question:

Just wondering why we need the /E and the /S flag at the same time? Surely /E already does the job of /S (but also includes empty sub-folders)?

Is it to do with the addition of the trailing backslash on the source location?

Offline

#4 26 Nov 2009 21:02

insthink
Member
Registered: 24 Oct 2009
Posts: 51

Re: ROBOCOPY: strange error

my bad on the /e /s
you only need /e OR /s [depending of whether you want empty subfolders or not]

Offline

Board footer

Powered by