为什么我不能存储它?
FOR %%a IN ("some_file_path") DO (
SET FileDateTime=%%~ta
echo !FileDateTime!
)
输出是~ta
这也不起作用。
Setlocal EnableDelayedExpansion
FOR %%a IN ("some_file_path") DO (
SET FileDateTime=!!~ta
)
答案 0 :(得分:1)
此类代码有效
SETLOCAL EnableDelayedExpansion
FOR %%a IN ("some_file_path") DO (
ECHO %%a
SET FileDateTime=%%~ta
ECHO !FileDateTime!
)
答案 1 :(得分:1)
这些也应该有效:
A:
FOR %%a IN ("some_file_path") DO (
SET FileDateTime=%%~ta
call echo %%FileDateTime%%
)
B:
FOR %%a IN ("some_file_path") DO (
SET FileDateTime=%%~ta
)
echo %FileDateTime%