FOR %%? IN (file_to_be_queried) DO (
ECHO File Name Only : %%~n?
ECHO File Extension : %%~x?
ECHO Name in 8.3 notation : %%~sn?
ECHO File Attributes : %%~a?
ECHO Located on Drive : %%~d?
ECHO File Size : %%~z?
ECHO Last-Modified Date : %%~t?
ECHO Parent Folder : %%~dp?
ECHO Fully Qualified Path : %%~f?
ECHO FQP in 8.3 notation : %%~sf?
ECHO Location in the PATH : %%~dp$PATH:?
)
我在http://www.robvanderwoude.com/battech_fileproperties.php看到了这个。
但是当我尝试应用它时 在循环中我使用“set”
SET datetime_t = %%〜t?
Echo datetime_t%datetime_t%>的Result.txt
仅在文件中显示
datetime_t
datetime_t
datetime_t
datetime_t
这个变量发生了什么?是空的吗?
答案 0 :(得分:1)
试试这个:
setlocal enabledelayedexpansion
Rem Above is required for this to work
FOR %%? IN (file_to_be_queried) DO (
ECHO File Name Only : %%~n?
ECHO File Extension : %%~x?
ECHO Name in 8.3 notation : %%~sn?
ECHO File Attributes : %%~a?
ECHO Located on Drive : %%~d?
ECHO File Size : %%~z?
ECHO Last-Modified Date : %%~t?
ECHO Parent Folder : %%~dp?
ECHO Fully Qualified Path : %%~f?
ECHO FQP in 8.3 notation : %%~sf?
ECHO Location in the PATH : %%~dp$PATH:?
SET datetime_t=%%~t?
Echo datetime_t !datetime_t! > result.txt
Rem Notice use of "!"
)
这应该可以正常工作。
莫纳