如何在 XP 和 Win 2000 的 cmd 中格式化 dir 命令
How to format dir command in cmd for XP and Win 2000
当我在 win XP 中使用 dir 命令时 returns 所有类型的信息:
Volume in drive C is OSDisk
Volume Serial Number is AEF7-B35F
Directory of C:\Users\bd250124\Desktop\test
06/11/2015 12:14 PM <DIR> .
06/11/2015 12:14 PM <DIR> ..
06/11/2015 12:14 PM 10 test01.txt
06/11/2015 12:13 PM 0 test02.txt
2 File(s) 10 bytes
2 Dir(s) 261,280,952,320 bytes free
问题是我不需要所有这些信息,我只需要文件名和上次写入时间。有没有什么方法可以格式化它,google 没有返回任何结果,重复一遍我使用的是 win XP 和 2000。
命令行:
for /F "delims=" %G in ('dir /B /A:-D') do @echo %~tG %G
批次(注意 %%G
而不是 %G
):
for /F "delims=" %%G in ('dir /B /A:-D') do @echo %%~tG %%G
资源(必读):
for %a in ("c:\somewhere\*" "d:\here\*.txt" "\server\share\path\*.doc") do @echo %~ta %~fa
使用简单的 for
命令,指明您要处理的所有文件集,并为找到的每个文件(由 %a
引用)回显其时间戳 (%~ta
)以及文件的完整路径 (%~fa
)
为了在批处理文件中使用,需要转义百分号,将每个 %
替换为 %%
当我在 win XP 中使用 dir 命令时 returns 所有类型的信息:
Volume in drive C is OSDisk
Volume Serial Number is AEF7-B35F
Directory of C:\Users\bd250124\Desktop\test
06/11/2015 12:14 PM <DIR> .
06/11/2015 12:14 PM <DIR> ..
06/11/2015 12:14 PM 10 test01.txt
06/11/2015 12:13 PM 0 test02.txt
2 File(s) 10 bytes
2 Dir(s) 261,280,952,320 bytes free
问题是我不需要所有这些信息,我只需要文件名和上次写入时间。有没有什么方法可以格式化它,google 没有返回任何结果,重复一遍我使用的是 win XP 和 2000。
命令行:
for /F "delims=" %G in ('dir /B /A:-D') do @echo %~tG %G
批次(注意 %%G
而不是 %G
):
for /F "delims=" %%G in ('dir /B /A:-D') do @echo %%~tG %%G
资源(必读):
for %a in ("c:\somewhere\*" "d:\here\*.txt" "\server\share\path\*.doc") do @echo %~ta %~fa
使用简单的 for
命令,指明您要处理的所有文件集,并为找到的每个文件(由 %a
引用)回显其时间戳 (%~ta
)以及文件的完整路径 (%~fa
)
为了在批处理文件中使用,需要转义百分号,将每个 %
替换为 %%