批处理文件:获取文件夹的创建日期 [英] Batch file : get the creation date of a folder

查看:464
本文介绍了批处理文件:获取文件夹的创建日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在纯批处理文件中获得文件夹的创建日期(无超级脚本)?特别是,我想将其放入此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 :

  1. fileModifiedTime.bat -获取上次修改时间具有与设置无关的格式的文件.基于 robocopy
  2. fileTimes.bat -获取文件时间戳记与 WMIC
  3. dirTimes.bat -获取目录时间戳与 WMIC
  4. fileTimesJS.bat -文件时间带有 jscript
  5. 的图章
  6. dirTimesJS.bat -目录时间带有 jscript
  7. 的图章
  8. fileTimesNET.bat -文件 .NET
  9. 创建时间戳记
  10. dirTimesNET.bat -目录 .NET
  11. 创建时间戳记
  1. fileModifiedTime.bat - gets last modified time of file with settings independent format.Based on robocopy
  2. fileTimes.bat - gets file time stamps with WMIC
  3. dirTimes.bat - gets directory time stamps with WMIC
  4. fileTimesJS.bat - file time stamps with jscript
  5. dirTimesJS.bat - directory time stamps with jscript
  6. fileTimesNET.bat - file time stamps with .NET
  7. dirTimesNET.bat - dir time stamps with .NET

这篇关于批处理文件:获取文件夹的创建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆