I’m trying to create a minor batch process that reads the current directory for log files and parses each file that is found by the last 4 characters (the year) in the file’s name.
I’d like to take each file that matches a given year, say 2010, and take each of these and archive it into a *.ZIP file. In other words, I’m just trying to zip-up all 2010 log files…
Here’s where I am right now:
@ECHO OFF
CLS
::
:: If the archives directory doesn't exist, create it...
::
:START
ECHO "Step 1..."
IF NOT EXIST archives GOTO CREATE_DIR
::
:: Subroutine to create archives directory...
::
:CREATE_DIR
ECHO "Step 2..."
MKDIR archives
::
:: Initialize main routine...
::
:INITIALIZE
ECHO "Step 3..."
FOR %%G IN (*.log) DO (CALL :PARSE %%G)
PAUSE
::
:: Parse filename...
::
:PARSE
ECHO %1
EXIT /b
The token and delims modifiers / switches don’t work when I include them causing the entire batch file to simply not work. Any insight into this is appreciated.
Off Topic:
Not bashing SP or anything, but does anyone know what’s up with this new theme? This white / bleach-bone coloring scheme really stinks. It’s hard to make the distinction at times between input forms and overall website controls… Any word on this?
If you could use powershell to handle this it would be alot easier. Failing that I’d advise using vbscript. I think you might be able to figure out how to do it using MS dos batch files but they aren’t really meant for this sort of thing.
Check the general announcements section for more than you ever wanted to hear about the redesign/forum update.
I went with the batch route because I thought that using Windows Server 2003’s “Scheduled Tasks” to do this would be as easy as it gets. If I go with something like VBScript, how would I implement it inside that environment? I’ve worked with VBScript before but it was with things like PHP and Excel files… Not batch processing. :-\
We run lots of powershell on Windows Server 2003, and we’ve done a bit of vbs. Key trick is that you can pass the script to execute and other commands by calling: