Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Need some batch file help please


(!)

0writer's Avatar
0writer 0writer is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Nov 2011
Experience: Advanced
21-Nov-2011, 03:18 AM #1
Need some batch file help please
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
Squashman's Avatar
Trusted Advisor with 19,660 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Nov-2011, 08:04 AM #2
So lets see the code you have started so far.
0writer's Avatar
0writer 0writer is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Nov 2011
Experience: Advanced
21-Nov-2011, 08:14 AM #3
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's Avatar
Trusted Advisor with 19,660 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Nov-2011, 08:26 AM #4
A lot of the code you have already is VB script. Can't help you with that. I don't know much about VBscript.
centauricw's Avatar
centauricw centauricw is offline
Member with 435 posts.
 
Join Date: Jun 2010
Location: Atlanta GA
Experience: Advanced
26-Nov-2011, 09:37 PM #5
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.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑