Jump to content

make sure file is written to and closed before renaming


geekpie

Recommended Posts

Hi

This is all on XP.  I am using CLI php to loop through a folder converting all .ppts to pdfs.

I use pdfcreator.exe for this.  the relevant php line is:

 

$convertproc  = proc_open('"C:\Program Files\PDFCreator\PDFCreator.exe" /NoStart /PF'.$file, $descriptorspec, $retval);

 

(I've also used exec() in earlier efforts).

I then get the process id using

 

proc_get_status($convertproc);

 

and pause until the process is finished, then close the process:

 

while($procstatus['running']==1 )

{

  $procstatus = proc_get_status($convertproc);

}

proc_close($convertproc);

 

Then I try to rename the file:

 

$output = exec('ren '.$newfile .' '. $finalname, $output, $returnval);

 

However, the new pdf file seems to get written to *after* the process has finished running, so the rename fails.  I've tried filesize(), is_readable(file) and all sorts of others but to no avail.

 

Any advice?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.