标题: [系统相关] 批处理能否批量显示文件属性修改日期(要显示到秒)? [打印本页]
作者: xiongdeqin 时间: 2022-9-1 13:01 标题: 批处理能否批量显示文件属性修改日期(要显示到秒)?
问题如题,如下代码能批量显示文件属性中修改日期,但是没有显示几点几分几秒修改的,只显示几点几分。
求教,怎么才能显示 几点几分几秒?- @echo off&setlocal EnableDelayedExpansion
- for /f "delims=" %%f in ('dir /b /s D:\TEST') do (
- set fileDateTime=%%~tf
- set fileName=%%~dpnxf
- echo !fileName!----!fileDateTime!
- )
- pause
复制代码
作者: hfxiang 时间: 2022-9-1 13:29
for /f "usebackq tokens=*" %a in (`forfiles /p . /m *.* /c "cmd /c echo @path,@fdate,@ftime"`) do @echo %a
作者: WHY 时间: 2022-9-1 14:23
- PowerShell "dir *.* -Recurse | forEach{$_.FullName + '----' + $_.LastWriteTime.ToString('yyyy/MM/dd HH:mm:ss')}"
复制代码
作者: Batcher 时间: 2022-9-1 16:27
回复 1# xiongdeqin
test.bat- ' 2>nul 3>nul&@echo off&cls
- ' &start wscript.exe /nologo /e:vbs %0&exit
- set objFSO = CreateObject("Scripting.FileSystemObject")
- ' 结果写入哪个文件
- set objDstFile = objFSO.OpenTextFile("C:\Test\To\Result.txt",2,True)
- ' 获取哪个文件夹下的文件
- set objFiles = objFSO.GetFolder("C:\Test\From").Files
- for each objFile in objFiles
- objDstFile.Write objFile & " --- " & objFile.DateLastModified & vbcrlf
- next
- objDstFile.Close
复制代码
作者: WHY 时间: 2022-9-1 21:21
- @echo off
- setlocal enabledelayedexpansion
-
- set "p=%~p0"
-
- for /f "tokens=1*" %%i in ('wmic DataFile Where "Drive='%~d0' And Path='%p:\=\\%'" Get LastModified^,Name^|find "\"') do (
- set "dtm=%%i"
- for /f "delims=" %%k in ("%%j") do (
- echo;%%~fk----!dtm:~0,4!/!dtm:~4,2!/!dtm:~6,2! !dtm:~8,2!:!dtm:~10,2!:!dtm:~12,2!
- )
- )
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |