Need some batch file help please

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

0writer

Thread Starter
Joined
Nov 21, 2011
Messages
2
Hello,

I am trying to write a batch file to "capture" multiple txt files burried within multiple directories and then zip the files it has "captured" and email it.

To explain a bit better, I have a folders called Logs and within this are folders which a named in YYYYMMDD format. Within each of these folders is a text file called SMSLog_YYYYMMDD.txt

I'm trying to create a batch file that I can schedule to run at the end of each month that will grab all of the *.txt files for that month, zip them and email them to me.

We have a local email server that we can use to send the email which is smtp.

I'd really appriciate any help you can offer.

Thanks in advance
 

0writer

Thread Starter
Joined
Nov 21, 2011
Messages
2
Well, all I have so far are snipets of code from browsing but because I don't have the knowledge to chop and change them, that's where I'm getting stuck.

Here is some code I've found for zipping (but it will only zip a specific file)


Code:
set FILETOZIP=c:\ue_english.txt       set TEMPDIR=C:\temp738     rmdir %TEMPDIR%     mkdir %TEMPDIR%     copy %FILETOZIP% %TEMPDIR%      echo Set objArgs = WScript.Arguments > _zipIt.vbs     echo InputFolder = objArgs(0) >> _zipIt.vbs     echo ZipFile = objArgs(1) >> _zipIt.vbs     echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> _zipIt.vbs     echo Set objShell = CreateObject("Shell.Application") >> _zipIt.vbs     echo Set source = objShell.NameSpace(InputFolder).Items >> _zipIt.vbs     echo objShell.NameSpace(ZipFile).CopyHere(source) >> _zipIt.vbs     echo wScript.Sleep 2000 >> _zipIt.vbs      CScript  _zipIt.vbs  %TEMPDIR%  C:\someArchive.zip      pause
I've got some vbs code to send an email using our internal smtp server and that's working nicely (I use it already for some other stuff).

Thanks,
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
A lot of the code you have already is VB script. Can't help you with that. I don't know much about VBscript.
 
Joined
Jun 26, 2010
Messages
444
I would go ahead and write the VBScript script file as a standalone .vbs file rather than trying to create it as part of the batch file. This will make debugging the the VBScript much, much easy. Then you can call the VBScript from a batch file, passing in any arguments it needs.

Code:
cscript //nologo c:\path-to-my-script-folder\myscript.vbs Argument1 "Argument 2 with spaces"
I like using cscript (//nologo suppresses the logo banner), but if you're not using anything only supported by cscript, you can use wscript instead.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top