批处理文件:获取文件夹的创建日期 [英] Batch file : get the creation date of a folder
问题描述
有没有一种方法可以在纯批处理文件中获得文件夹的创建日期(无超级脚本)?特别是,我想将其放入此for循环中:
Is there a way to get the creation date of a folder in pure batch file (no power script)? In particular, I would like to get it inside this for loop:
FOR /f "tokens=*" %%G in ('dir /b /s /a:d "C:\asdf\*"') DO CALL :loopbody "%%~tG" "%%G"
此循环调用函数",其中文件夹的修改日期为第一个参数,文件夹的路径为第二个参数.
This loop call a 'function' with the modification date of the folder as the first parameter and the path of the folder as the second parameter.
推荐答案
for /f "skip=5 tokens=1,2 delims= " %%A in ('dir /ad /od /tc "dirname"') do (
echo %%A-%%B
goto :end_loop
)
:end_loop
尝试一下.结果将取决于您的时间设置,可能需要调整标记和delims.WMIC
和Hybrid jscript/vbscript也可以,但是创建脚本需要一些时间.
Try this.Result will depend on your time settings and probably you'll need to tune the tokens and delims.It's possible also with WMIC
and hybrid jscript/vbscript ,but will need a few minutes to create a script.
编辑,带有wmic:
WMIC path Win32_Directory WHERE name='C:\\SomeDir' get creationdate
编辑:以下是一些准备使用的脚本,它们使用不同的方法来获取文件或目录时间戳记:
EDIT Here are some ready to use scripts using different methods to acquire file or directory time stamps :
- fileModifiedTime.bat -获取上次修改时间具有与设置无关的格式的文件.基于 robocopy
- fileTimes.bat -获取文件时间戳记与 WMIC
- dirTimes.bat -获取目录时间戳与 WMIC
- fileTimesJS.bat -文件时间带有 jscript 的图章
- dirTimesJS.bat -目录时间带有 jscript 的图章
- fileTimesNET.bat -文件 .NET 创建时间戳记
- dirTimesNET.bat -目录 .NET 创建时间戳记
- fileModifiedTime.bat - gets last modified time of file with settings independent format.Based on robocopy
- fileTimes.bat - gets file time stamps with WMIC
- dirTimes.bat - gets directory time stamps with WMIC
- fileTimesJS.bat - file time stamps with jscript
- dirTimesJS.bat - directory time stamps with jscript
- fileTimesNET.bat - file time stamps with .NET
- dirTimesNET.bat - dir time stamps with .NET
这篇关于批处理文件:获取文件夹的创建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!