Solved

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

Posted on 2016-08-05
10
37 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 22

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 69

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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
 
LVL 69

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 69

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Whitelisting applications 2 27
Locating a GPO setting 3 42
Detect Failed Logins within Event Viewer 4 35
AD FSMO role placing consideration and best practice ? 3 49
I was asked if I could set up a fax machine so that incoming faxes were delivered to people's Exchange inboxes and so that they could send faxes from their desktops without needing to print the document first.  I knew it was possible but I had no id…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

820 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