set variable in forfiles in for cycle
问题 @Echo On FOR %%f IN (*.jpg) DO ( forfiles /M "%%f" /C "cmd /V:ON /c set fn=@ftime" echo %%fn%% ) pause I want to get @ftime in FOR loop, but this isn't working. Maybe there is another way to get modify time of the file? 回答1: In your method, you are setting a variable fn within the cmd instance that is opened by forfiles , but this variable is no longer available in the cmd instance that runs your script. You can use the ~t modifier of the for variable (so %%~tf in your code) to get the