</head> <body> <h1>FileSetTime</h1> <p>Changes the datetime stamp of one or more files or folders. Wildcards are supported.</p> <pre class="Syntax"><span class="func">FileSetTime</span> <span class="optional">, YYYYMMDDHH24MISS, FilePattern, WhichTime, OperateOnFolders?, Recurse?</span></pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>YYYYMMDDHH24MISS</dt> <dd><p>If blank or omitted, it defaults to the current time. Otherwise, specify the time to use for the operation (see Remarks for the format). Years prior to 1601 are not supported.</p> <p>This parameter is an <a href="../Variables.htm#Expressions">expression</a>. Consequently, if multiple variables need to be concatenated to form a single timestamp, the <a href="../Variables.htm#concat">dot operator</a> should be used instead of percent signs. Por exemplo: <code>FileSetTime, Year <strong>.</strong> Month <strong>.</strong> Day, C:\My File.txt</code>.</p></dd> <dt>FilePattern</dt> <dd><p>The name of a single file or folder, or a wildcard pattern such as C:\Temp\*.tmp. <em>FilePattern</em> is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified.</p> <p>If omitted, the current file of the innermost enclosing <a href="LoopFile.htm">File-Loop</a> will be used instead.</p></dd> <dt>WhichTime</dt> <dd><p>If blank or omitted, it defaults to M (modification time). Otherwise, specify one of the following letters to set which timestamp should be changed:</p> <ul> <li>M = Modification time</li> <li>C = Creation time</li> <li>A = Last access time</li> </ul> </dd> <dt>OperateOnFolders?</dt> <dd><p>If blank or omitted, it defaults to 0 (only files are operated upon). Otherwise, specify one of the following digits:</p> <ul> <li>0 = Folders are not operated upon (only files).</li> <li>1 = All files and folders that match the wildcard pattern are operated upon.</li> <li>2 = Only folders are operated upon (no files).</li> </ul> <p class="note"><strong>Observação</strong>: If <em>FilePattern</em> is a single folder rather than a wildcard pattern, it will always be operated upon regardless of this setting.</p> <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd> <dt>Recurse?</dt> <dd><p>If blank or omitted, it defaults to 0 (subfolders are not recursed into). Otherwise, specify one of the following digits:</p> <ul> <li>0 = Subfolders are not recursed into.</li> <li>1 = Subfolders are recursed into so that files and folders contained therein are operated upon if they match <em>FilePattern</em>. All subfolders will be recursed into, not just those whose names match <em>FilePattern</em>. However, files and folders with a complete path name longer than 259 characters are skipped over as though they do not exist. Such files are rare because normally, the operating system does not allow their creation.</li> </ul> <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd> </dl> <h2 id="Error_Handling">Error Handling</h2> <p><span class="ver">[v1.1.04+]</span>: This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p> <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to the number of files that <u>failed</u> to be changed or 0 otherwise. If the specified timestamp is invalid, or <em>FilePattern</em> resolves to a blank value, ErrorLevel is set to 1.</p> <p>If files were found, <a href="../Variables.htm#LastError">A_LastError</a> is set to 0 (zero) or the result of the operating system's GetLastError() function immediately after the last failure. Otherwise A_LastError contains an error code that might indicate why no files were found.</p> <h2 id="Remarks">Remarks</h2> <p>A file's last access time might not be as precise on FAT16 &amp; FAT32 volumes as it is on NTFS volumes.</p> <p id="YYYYMMDD">The elements of the YYYYMMDDHH24MISS format are:</p> <table class="info"> <tr> <th>Element</th> <th abbr="Descr">Descrição</th> </tr> <tr> <td>YYYY</td> <td>The 4-digit year</td> </tr> <tr> <td>MM</td> <td>The 2-digit month (01-12)</td> </tr> <tr> <td>DD</td> <td>The 2-digit day of the month (01-31)</td> </tr> <tr> <td>HH24</td> <td>The 2-digit hour in 24-hour format (00-23). For example, 09 is 9am and 21 is 9pm.</td> </tr> <tr> <td>MI</td> <td>The 2-digit minutes (00-59)</td> </tr> <tr> <td>SS</td> <td>The 2-digit seconds (00-59)</td> </tr> </table> <p>If only a partial string is given for YYYYMMDDHH24MISS (e.g. 200403), any remaining element that has been omitted will be supplied with the following default values:</p> <ul> <li>MM = Month 01</li> <li>DD = Day 01</li> <li>HH24 = Hour 00</li> <li>MI = Minute 00</li> <li>SS = Second 00</li> </ul> <p>The built-in variable <a href="../Variables.htm#Now">A_Now</a> contains the current local time in the above format. Similarly, <a href="../Variables.htm#NowUTC">A_NowUTC</a> contains the current Coordinated Universal Time.</p> <p class="note"><strong>Note:</strong> Date-time values can be compared, added to, or subtracted from via <a href="EnvAdd.htm">EnvAdd</a> and <a href="EnvSub.htm">EnvSub</a>. Also, it is best to not use greater-than or less-than to compare times unless they are both the same string length. This is because they would be compared as numbers; for example, 20040201 is always numerically less (but chronologically greater) than 200401010533. So instead use <a href="EnvSub.htm">EnvSub</a> to find out whether the amount of time between them is positive or negative.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="FileGetTime.htm">FileGetTime</a>, <a href="FileGetAttrib.htm">FileGetAttrib</a>, <a href="FileSetAttrib.htm">FileSetAttrib</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="FileGetVersion.htm">FileGetVersion</a>, <a href="FormatTime.htm">FormatTime</a>, <a href="LoopFile.htm">File-loop</a>, <a href="EnvAdd.htm">EnvAdd (date math)</a>, <a href="EnvSub.htm">EnvSub (date difference)</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExOmitted"> <p><a class="ex_number" href="#ExOmitted"></a> Sets the modification time to the current time for all matching files.</p> <pre>FileSetTime, , C:\temp\*.txt</pre> </div> <div class="ex" id="ExModTime"> <p><a class="ex_number" href="#ExModTime"></a> Sets the modification date (time will be midnight).</p> <pre>FileSetTime, 20040122, C:\My Documents\test.doc</pre> </div> <div class="ex" id="ExCreateTime"> <p><a class="ex_number" href="#ExCreateTime"></a> Sets the creation date. The time will be set to 4:55pm.</p> <pre>FileSetTime, 200401221655, C:\My Documents\test.doc, C</pre> </div> <div class="ex" id="ExPattern"> <p><a class="ex_number" href="#ExPattern"></a> Changes the mod-date of all files that match a pattern. Any matching folders will also be changed due to the last parameter.</p> <pre>FileSetTime, 20040122165500, C:\Temp\*.*, M, 1</pre> </div> </body> </html>