User Tools

Site Tools


windows_batch_scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
windows_batch_scripting [2015/07/23 15:19] – add "Check if the current batch script has admin rights" zertrinwindows_batch_scripting [2015/08/04 20:18] (current) – add "Delete folders older than 10 days" zertrin
Line 117: Line 117:
     pause >nul     pause >nul
 </code> </code>
 +
 +
 +==== Get current time in a locale independent way ====
 +
 +from http://serverfault.com/questions/227345/locale-unaware-date-and-time-in-batch-files
 +
 +<code>
 +FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') DO set DTS=%%a
 +set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%
 +</code>
 +
 +
 +==== Delete folders older than 10 days ====
 +
 +from http://stackoverflow.com/questions/5497211/batch-file-to-delete-folders-older-than-10-days-in-windows-7
 +
 +<code>
 +FORFILES /S /D -10 /C "cmd /c IF @isdir == TRUE rd /S /Q @path"
 +</code>
 +
windows_batch_scripting.1437635975.txt.gz · Last modified: by zertrin