Solved

Need help with a BATCH file

Posted on 2012-03-14
7
374 Views
Last Modified: 2012-03-14
Hi,

Scenario:

-We are using the following batch file which is configured with an AT task.

@echo off
cd C:\Program Files (x86)\JAM Software\TreeSize Professional\
TreeSize.exe /HTML "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport.HTML" /EXPAND 2 \\ss1\is_shared
blat.exe "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport.HTML" -to email1@domain.com -f storagealerts@domain.com -server exchange.domain.local

-The script runs once every moth
-Through TreeSize.exe /HTML we are creating an output HTML file which creates a report the report is named "IS_SHARED_StorageReport.HTML" and it is placed on network share.
-The report is sent via email to a number of recepients. We use BLAT.EXE + the name of the report to do it.  
-The report that is saved on the network share is overwriten every moth since we are using the same name.

Issue:

Since the report is saved on the network share with the same name overwrites the previous one which is now becoming a problem because we don't have any data for trending.

Question:

We are trying to figure out if the is any way to get the batch file modified in order to create a file with a new name. For example something like this:

IS_SHARED_StorageReport_03/14/2012.HTML
IS_SHARED_StorageReport_04/14/2012.HTML
IS_SHARED_StorageReport_05/14/2012.HTML
IS_SHARED_StorageReport_06/14/2012.HTML
etc.

Could someone help us out with this one?

Thank you!
0
Comment
Question by:llarava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:micropc1
ID: 37721331
Try this...

@echo off
FOR /f "tokens=2 delims= " %%D in ('echo %DATE:/=%') do SET DATEN=%%D
cd C:\Program Files (x86)\JAM Software\TreeSize Professional\
TreeSize.exe /HTML "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport_%DATEN%.HTML" /EXPAND 2 \\ss1\is_shared
blat.exe "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport.HTML" -to email1@domain.com -f storagealerts@domain.com -server exchange.domain.local

Open in new window

0
 
LVL 1

Expert Comment

by:altzar
ID: 37721424
you can add those line at the begining of  the batch :

Set YEAR=%DATE:~10,4%
Set MONTH=%DATE:~4,2%
Set DAY=%DATE:~7,2%
Set CURDATE=%YEAR%-%MONTH%-%DAY%

then use %CURDATE% in the file name

so your batch will look like this :

@echo off

Set YEAR=%DATE:~10,4%
Set MONTH=%DATE:~4,2%
Set DAY=%DATE:~7,2%
Set CURDATE=%YEAR%-%MONTH%-%DAY%

cd C:\Program Files (x86)\JAM Software\TreeSize Professional\

TreeSize.exe /HTML "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport_%CURDATE%.HTML" /EXPAND 2 \\ss1\is_shared

blat.exe "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport_%CURDATE%.HTML" -to email1@domain.com -f storagealerts@domain.com -server exchange.domain.local
0
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
ID: 37721444
I just realized I forgot to include %DATEN% in the filename for blat.exe, so corrected it would be...

@echo off
FOR /f "tokens=2 delims= " %%D in ('echo %DATE:/=%') do SET DATEN=%%D
cd C:\Program Files (x86)\JAM Software\TreeSize Professional\
TreeSize.exe /HTML "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport_%DATEN%.HTML" /EXPAND 2 \\ss1\is_shared
blat.exe "\\ss1\IS_Shared\Weekly Storage Reports\IS_SHARED_StorageReport_%DATEN%.HTML" -to email1@domain.com -f storagealerts@domain.com -server exchange.domain.local

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:llarava
ID: 37721623
micropc1,

This one seems to work. The only issue is that I think that blat.exe needs a litle time catch up with the HTML file creation. Basically I get an email but it looks like raw code.

Would the script wait until the HTML file is fully generated and then send the email through BLAT.EXE?
0
 
LVL 1

Expert Comment

by:altzar
ID: 37721633
yes, a batch file is sequential
0
 

Author Comment

by:llarava
ID: 37721680
That is what I thought...

Well BLAT says something like this "Failed to open registry key for Blat Profile, using default. Failed to open registry key for blat
0
 
LVL 7

Expert Comment

by:micropc1
ID: 37721715
You may need to specify that the email is in HTML format. Try using blat's -html parameter to set the encoding to text/html or attaching the html file using -attacht.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question