For loop runs in command prompt screen but not in cmd file??
Posted: 08 Aug 2013 08:17
When I open a command prompt window and run each of the lines it does exactly what I want it to do.
-Variable(mm) assigned to current time minutes
-Variable (ff)assigned to File time minutes
- Variable(cc) assigned to current time minutes minus File time Minutes
-If CC is greater than 10 then I have an error
However when I create a '.cmd' file and run it get the error "~ta was unexpected at this time."on the highlighted line below.
echo on
cd..
cd workdir\CUSTDCHECK
IF NOT EXIST P:\Gensrvnt\workdir\CUSTDCHECK\o_100_00000000* GOTO end
REM GET CURRENT TIME(MINUTES only!!)
set mm=%time:~3,-6%
REM get date time of files in folder &REM GET FILE TIME( IN MINUTES!!)
for %a in (*.*) do set FileDate=%~ta
set ff=%filedate:~14%
REM Calculate the difference between minutes of current time minus minutes of the file
set /a cc= %mm%-%ff%
REM if difference is more than 10 then we have an error.
if /i %cc% GTR 10 (echo Error) ELSE echo no error
:end
echo this is the end my friend!
I would greatly appreciate some help on this?
-Variable(mm) assigned to current time minutes
-Variable (ff)assigned to File time minutes
- Variable(cc) assigned to current time minutes minus File time Minutes
-If CC is greater than 10 then I have an error
However when I create a '.cmd' file and run it get the error "~ta was unexpected at this time."on the highlighted line below.
echo on
cd..
cd workdir\CUSTDCHECK
IF NOT EXIST P:\Gensrvnt\workdir\CUSTDCHECK\o_100_00000000* GOTO end
REM GET CURRENT TIME(MINUTES only!!)
set mm=%time:~3,-6%
REM get date time of files in folder &REM GET FILE TIME( IN MINUTES!!)
for %a in (*.*) do set FileDate=%~ta
set ff=%filedate:~14%
REM Calculate the difference between minutes of current time minus minutes of the file
set /a cc= %mm%-%ff%
REM if difference is more than 10 then we have an error.
if /i %cc% GTR 10 (echo Error) ELSE echo no error
:end
echo this is the end my friend!
I would greatly appreciate some help on this?