|
| ||||||||||
| Tags: bat file, batch file, cmd, command prompt, directory |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Formatting Modified Date Variable in Batch File
How do I format 'mydate' to mmddyyy? It currently reads mm/dd/yyyy hh:mm AM(PM) Code: ChDIR C:\Users\finanalyst1433\Desktop\New folder\Output\
SETLOCAL enabledelayedexpansion
FOR %%f IN (*.o_g) DO (
CALL C:\RTSimEXE\RTOutput.exe %cd%\%%f Month
set mydate=%%~Tf )
FOR %%f IN (*_Mon.csv) DO REN "%%f" "%%~nf_%mydate%%%~xf
SET deletestring=_Mon
FOR /f "delims==" %%F IN ('dir /b *.csv ^| FIND "%deletestring%"') DO (
SET oldfilename=%%F
SET newfilename=!oldfilename:%deletestring%=!
REN "!oldfilename!" "!newfilename!"
)
EXIT |
|
#2
| ||||
| ||||
| Re: Formatting Modified Date Variable in Batch File
Check the Windows Batch File (.bat) to get current date in MMDDYYYY format.: Code: @echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
echo %mydate%_%mytime% Code: For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b) |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Formatting Modified Date Variable in Batch File" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows 7 resetting modified date on Files automatically while moving | Dvimida | Operating Systems | 3 | 12-01-2012 07:48 AM |
| Windows batch file: set output of program to a variable? | supernoob | Windows Software | 5 | 17-10-2010 05:58 AM |
| How do i modified pst file in Outlook | Atilla | Windows Software | 4 | 30-04-2009 10:53 AM |
| Date and Time format in a BATCH File | RogerFielden | Software Development | 3 | 20-04-2009 11:47 AM |
| Batch file to create directory with a date in Windows 2003 | Aadimoolan | Window 2000 Help | 2 | 16-11-2007 01:55 AM |