View Full Version : batch file to script help! (WXP-Pro)
sokhy
07-10-2006, 01:19 PM
I had a batch file that worked perfectly using these command lines:
copy \\hmc-datapump\reports\15*.* \\hmc-datapump\reports\HTRAP.DAT
copy \\hmc-datapump\reports\HTRAP.DAT \\Ssiserver\ssiapp\renws\uploadp
del \\hmc-datapump\reports\15*.*
del \\hmc-datapump\reports\HTRAP.DAT
I need to convert this batch file to vbscript. Please help me on the syntax!
<P ID="edit"><FONT class="small">Edited by sokhy on 07/10/06 12:20.</FONT></P>
jdharm
07-10-2006, 10:23 PM
Could you tell us why the wildcards are needed? Wildcards aren't usable in vb scripts the same way they are in batch files so we'll need to handle/process the files differently. Which means we'll need to know exactly why they were necessary so we can write the scripts accordingly.
Josh
Yet another site soon to be neglected:<font color=green>
<a target="_blank" href=http://www.zachmax.com>www.zachmax.com</a></font color=green>
How about something simple like this to do the first copy....
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\hmc-datapump\reports")
Set fc = f.Files
For Each f1 in fc
if len(f1.name) > 2 then
if left(f1,2) = "15" then
f1.copy ("\\hmc-datapump\reports\HTRAP.DAT")
end if
end if
next
sokhy
07-11-2006, 02:16 PM
The wildcards are needed because there are more than one file in that directory that I need to extract and place into one file. For instance
150009.txt
150010.txt
120011.txt
needs to be in:
15.dat
Your original copy statement doesnt append them as written, it simply overwrites one on top of the other.
jdharm
07-12-2006, 10:24 AM
So according to the batch as you have it posted the contents of HTRAP.DAT will be the contents of the last 15*.* file copied only.
Is this what you intend or do you want the contents of all of the 15*.* files added in turn to the end on the contents of the HTRAP.DAT file?
Will the 15*.* files always be .txt files?
Is there any particular reason you go through the intermediate step of copying to the HTRAP.DAT file on the DATAPUMP server instead of just going right to the SSISERVER?
I'm not being nosy with this, just getting details to try to write the script to satisfy your needs.
Josh
Yet another site soon to be neglected:<font color=green>
<a target="_blank" href=http://www.zachmax.com>www.zachmax.com</a></font color=green>
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.