geekpie Posted August 11, 2009 Share Posted August 11, 2009 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? Link to comment https://forums.phpfreaks.com/topic/169742-make-sure-file-is-written-to-and-closed-before-renaming/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.