0

I'm trying to move files from a UNIX/Windows directory over to a SharePoint directory via a batch file. I know that the command that I want to use is just a simple move g:\...\*.* z:\ but I do not want to try to move any file that is currently open. Is there a way to check if files in a directory are open/in use and then only perform the move on the non open files?

Bigby
  • 163
  • 1
  • 4
  • 11
  • Possible [duplicate](http://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script) – Bali C Jun 07 '12 at 13:59
  • which OS controls source directory? Is it local fs (ntfs)? – wmz Jun 07 '12 at 16:39
  • The batch file will be run on a Windows Server machine that has both of the directories mapped. – Bigby Jun 07 '12 at 16:43

1 Answers1

1

On Unix you could use fuser, on Windows Sysinternals handle utilities respectively to query what processes have a file open.

Bear in mind that both of those must be executed on a system which controls source filesystem, not on your copy machine.

General problem with this approach is that check-move operation is not atomic: you may never be sure that file status have not changed after you checked but before you start moving/copying, however if I correctly assume that you have a scenario with producer which puts something on your shared drive - to be consumed by Sharepoint, and you want to make sure it's 'baked' before you attempt move - then a common practice is to control this on producer side by moving it to shared resource only when work on it is completed. If you have no direct control over the producer you can achieve this by using utitilies mentioned above

wmz
  • 3,525
  • 1
  • 12
  • 21