rar C:\Backup\testBackup-%date:~-10,2%-%date:~-7,2%-%date:~-4,4%.rar c:\inetpub
currently when WinRAR creates the backup.rar the date format shows as 12/12/12 I would rather if it was Jan-12-2012
an help would be appreciated.
thanks in advance
Help with Batch Date
Moderator: DosItHelp
Re: Help with Batch Date
slem wrote:rar C:\Backup\testBackup-%date:~-10,2%-%date:~-7,2%-%date:~-4,4%.rar c:\inetpub
currently when WinRAR creates the backup.rar the date format shows as 12/12/12 I would rather if it was Jan-12-2012
12th dec 2012, Jan 12 2012
The current date is in July 2014. How do you get your dates?
Re: Help with Batch Date
Not too mention that it is a lot easier to work with dates in file names when they are formatted YYYY-MM-DD as the dir command does not sort file names logically like Windows Explorer does.
Re: Help with Batch Date
+1 That's a tip worth taking notice of, if you need to handle your files with a command prompt.
Re: Help with Batch Date
I understand, the date was just an example, but would be nice to have the month as a 3 letter format
Re: Help with Batch Date
See if this helps you - it provides three variables that you can use, and change.
Code: Select all
@echo off &setlocal
copy nul "%TEMP%\~.ddf" >nul
makecab /D RptFileName="%TEMP%\~.rpt" /D InfFileName="%TEMP%\~.inf" -f "%TEMP%\~.ddf">nul
for /f "tokens=3-7" %%a in ('find /i "makecab"^<"%TEMP%\~.rpt"') do (
set "current-date=%%e-%%b-%%c"
set "current-time=%%d"
set "weekday=%%a"
)
del /q "%TEMP%\~.*"
echo %weekday% %current-date% %current-time%
pause
Re: Help with Batch Date
that works perfect, just did a few adjustments, and voila, thank you for the help,