Solved

Robocopy /mov How can i prohibit the file copy if the file is open?

Posted on 2016-08-05
10
29 Views
Last Modified: 2016-09-10
Hello,
i'am using robocopy with switch /mov for moving PDF files and it works.
If the PDF open, Robocopy copy the file to destination bat can not delete the source file.
How can i prohibit the file copy if the file is open?

I'am using : robocopy.exe C:\temp C:\new /MOV

Do you have any ideas?
Thank you very much,
kind regards
bounty457
0
Comment
Question by:bounty457
10 Comments
 
LVL 21

Expert Comment

by:yo_bee
ID: 41744084
That is weird. Robocopy skills locked files. That is what the /r:n /w:n switches are meant for.

From my experience with robocopy you would see an error and a default wait time of 30 seconds before the process tries again. It should not move or copy the file if there is a lock on it.  

What machine are your running robocopy from?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41744118
There are different modes to open a file, and depending on the one used by the PDF reader the files might be locked for change, but not reading. So RoboCopy is able to copy the file, but not to delete. If the delete fails, RoboCopy should delete the copy.
There are different releases of RoboCopy, each having some own issues, and using a different version might help if RoboCopy does not delete the copied file. Of course the copy will take place each run for nothing that way ...

Anyway, what's the point? /MOV moves the files, leaving only those being created newly or unable to delete. Next run it will check for the file, and either the file exists on the target as exact copy (if the target folder delete failed or didn't took place because of a bug or e.g. network failure), and nothing is copied but the delete retried; or it does not exist and is copied over again.

And another anyway: Why don't you use the move or rename command, which works much better if staying on the same file system (partition)?
0
 
LVL 1

Author Comment

by:bounty457
ID: 41744141
Hello,

i'am using MS Server 2008R2.
0
 
LVL 1

Author Comment

by:bounty457
ID: 41744150
Hello Qlemlo,

the strange thing is, that robocopy make a new file with _1 or _2 if the file exist.
What i need is a simple process.
1. Move the file from UNC Path to local.
2. If the Source is open in foxit reader do not copy (actualy the file is creating at a every batch run with extension *_1.pdf, *_2.pdf and so on)
3. If the file is closed make the move on next batch run

Thank you very much,
Kind regards
Bounty
0
 
LVL 1

Author Comment

by:bounty457
ID: 41744159
Hello,

correction:
The Extension _1, _2 is not from robocopy. The reason is another process...
Strange is, if i use .txt - open in MS Editor and .tif open in MS Paint the move is possible (the source is delete), for me ok. Only the PDF open in Foxit Reader will not deleted.
Kind Regrads
Bounty
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 68

Expert Comment

by:Qlemo
ID: 41744234
Notepad does not lock the file in any way. It loads the file into memory, then closes all handles. So you can do whatever you want with the file ...

For RoboCopy, it should work if you add /IS. I've just tested with an PDF and Adobe, and the result is that the file exists in both locations, and on next batch run isn't considered anymore because it is already on the target. This might be intentional or a bug; but if you add /IS it will try to move the file again.
0
 

Expert Comment

by:Member_2_7970779
ID: 41746237
Hello,

thank you very much for the answers.
I am looking for a process that make not a file copy if the file is open. He should check the file, and if deleting is possible, than make a copy.
In my case the following process delete the file. Next robocopy make a copy again.

Thank you very much,
kind regards
Bounty
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 41746308
I can only recommend to skip using RoboCopy for this purpose (there is no need to use it), and switch to the move command:
move \\server\share\path\*.pdf c:\temp\

Open in new window

This works properly if the file cannot be deleted (because of permission issues, or locked files as in your case). The command does not do anything if the file exists at the target - no issue here - and does not work for subfolders - which should not be an issue here either.
1
 
LVL 1

Author Comment

by:bounty457
ID: 41746990
Hi Qlemo,

thank you very much. This works fine.

Kind Regards
Bounty
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 41792441
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Qlemo (https:#a41746308)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

seth2740
Experts-Exchange Cleanup Volunteer
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now