in reply to File::Copy - move() function corrupting files

brainfiddle:

I don't know if the problem is due to moving PDF files when they're open or not. But if that's the problem, then I suggest you create the PDF files with a bogus extension (such as .WORK). After the file is successfully completed and closed, you can then rename it from XYZ.WORK to XYZ.PDF. This will prevent your program from detecting and working with PDF files before they're ready to go. (I use the same trick for file generators to prevent an FTP process from sending the file before it's complete.)

As I said, I don't know if that's your problem, though.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

  • Comment on Re: File::Copy - move() function corrupting files

Replies are listed 'Best First'.
Re^2: File::Copy - move() function corrupting files
by myelinviolin (Novice) on Aug 25, 2014 at 16:11 UTC
    I can't do it this way because the pdf files are initially created by Abobe PDF Printer and I don't think there is a way to change the extensions of what it prints to something besides .pdf

      Don't scan for files yourself, make the operating system notify you of changes in the filesystem (inotify or similar APIs). Make sure your code starts processing only after a new file (opened for writing) is closed. For inotify, this seems to be indicated by the IN_CLOSE_WRITE event.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)