Jump to content
Sign in to follow this  
Hobbyist

DOS file in Autoit

Recommended Posts

Hobbyist

I'm trying my hand at taking something in DOS and using it in Autoit.

But at this point I'm getting an error and not sure why.

I think the error is in the checking the day but don't know why.

I think it is the line:

if %cwday% LEQ 03 set /A m=%m%-01

This is to check the date and if it is still within the first three days of the month, use the previous month file. 

 Any help would be appreciated.

echo off
@title Month
FOR /F "tokens=2-4 delims=/-/ " %%A IN ("%date%") DO (
SET cwMonth=%%A
SET cwDay=%%B
SET cwYear=%%C
)
for /f "usebackq tokens=2 delims=/ " %%n in ('%date%') do set m=%%n
if %cwday% LEQ 03 set /A m=%m%-01 
set "m=0%m%"
set "m=%m:~-2%"
if "%m%" == "01" set month=January
if "%m%" == "02" set month=February
if "%m%" == "03" set month=March
if "%m%" == "04" set month=April
if "%m%" == "05" set month=May
if "%m%" == "06" set month=June
if "%m%" == "07" set month=July
if "%m%" == "08" set month=August
if "%m%" == "09" set month=September
if "%m%" == "10" set month=October
if "%m%" == "11" set month=November
if "%m%" == "12" set month=December
set abc=%month%
set efg=List.xls
set x=MY
set y=Files
set z=History
set xyz=%abc% %x% %y% %z% %efg%
start /max "" "%xyz%"

Share this post


Link to post
Share on other sites
BrewManNH

Why don't you just use AutoIt to do it? Batch files are so last century. ;)

Look at the date macros (@MDay, @MON, etc.) and the Date UDF that comes with AutoIt.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hobbyist

BrewManNH

WOW - didn't see ALL that was available.

Thanks for pointing that out. Much simpler to work with 'em.

Share this post


Link to post
Share on other sites
BrewManNH

:thumbsup:


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×