Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Getting the file size into a variable is simple - <code>for %%F in (filePath) do set "size=%%~zF"</code>.</p> <p>But I believe I can give you a much better solution.</p> <p>Unlike Unix, most Windows processes get an exclusive lock on a file when they are writing to it. Assuming your conversion process continuously locks the output file during processing, then you can simply use the following to test if the file is locked (still being processed) or not locked (finished processing):</p> <pre><code>( (call ) &gt;&gt;outputFile.ext ) 2&gt;nul &amp;&amp; ( echo The file is unlocked and ready for transfer ) || ( echo The file is still being created ) </code></pre> <p>The <code>(call )</code> syntax is simply a very fast command that does nothing - effectively a null op. This command is guaranteed not to have any output, so when you append the results of the command to your file, it is guaranteed not to change anything.</p> <p>If the file is already locked because it is still being processed by your conversion program, then the redirection will fail. The <code>2&gt;nul</code> simply hides any error message due to redirection failure, and the <code>&amp;&amp;</code> and <code>||</code> operators conditionally execute command(s) based on success or failure of prior command.</p> <p><strong>Update</strong></p> <p>The space in <code>(call )</code> is critical, allowing the "null op" to not return an error (errorcode=0). Take away the space, <code>(call)</code>, and the command returns an error (errorcode=1) which will break the lock detection algorithm. It is interesting that the form without a space returns an error without generating an error message. I believe those two commands are the most efficient way to clear or set the batch errorcode.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload