I need to add certain files to TodayDate.rar
for this I am using cmd
batch file with following code which is working fine.
"C:\Program Files\WinRAR\rar" a -agmmddyy ".rar"
Now I am changing above code and using If Condition
as in following code then it is not working. why?
if %time:~0,2% lss 13 (
"C:\Program Files\WinRAR\rar" a -agmmddyy " Morning.rar"
) else (
"C:\Program Files\WinRAR\rar" a -agmmddyy "Afternoon.rar"
)
Actually I need to do this Two time, first in the morning and second in afternoon that's why I added if condition
to evaluate time and write the Name of file with Morning
and Afternoon
accordingly.
UPDATE:
I have checked both conditions (before and after HH=13
) and its working fine, showing results "yes" and "no" respectively, using following code:
if %HH% LSS 13 (
echo "yes"
) else (
echo "no"
)
But when I used RAR
to above-mentioned code, it is not working. please help: showing no result
if %HH% LSS 13 (
"C:\Program Files\WinRAR\rar" a -agmmddyy "Morning .rar"
echo "yes"
) else (
"C:\Program Files\WinRAR\rar" a -agmmddyy "Afternoon .rar"
echo "no"
)
I tried to use following still No result:
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" & set "hh=%dt:~8,2%"
rem M=month D=day Y=Year h=hour
set datestamp=%MM%%DD%%YY%
echo %HH%
ren "CEEMEA & LATAM.Docx" "CEEMEA & LATAM %datestamp%.Docx"
"C:\Program Files\WinRAR\rar" a -agmmddyy ".rar" '''''' THIS LINE IS WORKING FINE
pause
if %HH% LSS 13 (
"C:\Program Files\WinRAR\rar" a -agmmddyy "Morning .rar"
echo "yes"
) else (
"C:\Program Files\WinRAR\rar" a -agmmddyy "Afternoon .rar"
echo "no"
)
pause