In the code that follows, change %
to %%
for use in batch file, for %~ta
syntax enter call /?
for %a in (MyFile.txt) do set FileDate=%~ta
Sample output:
for %a in (MyFile.txt) do set FileDate=%~ta
set FileDate=05/05/2020 09:47 AM
for %a in (file_not_exist_file.txt) do set FileDate=%~ta
set FileDate=
More Related Contents:
- windows batch file with goto command not working
- Batch program to to check if process exists
- How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?
- Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files
- How do you get the string length in a batch file?
- How do you loop through each line in a text file using a windows batch file?
- How to delete files/subfolders in a specific directory at the command prompt in Windows
- Batch script: how to check for admin rights
- Setting a system environment variable from a Windows batch file?
- How to correct variable overwriting misbehavior when parsing output?
- Batch script loop
- FORFILES date -after- (date calc in cmd file)
- Create an empty file on the commandline in windows (like the linux touch command)
- Calculate time difference in Windows batch file
- What is the proper way to test if a parameter is empty in a batch file?
- In Windows: How do you programatically launch a process in administrator mode under another user context?
- How do I shutdown, restart, or log off Windows via a bat file?
- How do I create a shortcut via command-line in Windows?
- Why does findstr not handle case properly (in some circumstances)?
- Why “The system cannot find the batch label specified” is thrown even if label exists?
- Batch script with for loop and pipe
- How to rename file by replacing substring using batch in Windows [closed]
- How to pass environment variables as parameters by reference to another batch file?
- Text garble in batch script for wmic command
- Execute multiple batch files concurrently and monitor if their process is completed
- How do I increment a folder name using Windows batch?
- Foolproof way to check for nonzero (error) return code in windows batch file
- Windows batch script to delete everything in a folder except one
- ERRORLEVEL vs %ERRORLEVEL% vs exclamation mark ERRORLEVEL exclamation mark
- Create a list or an array and print each item in Windows Batch