I'm having a problem, I want to run the below script on all files in a
folder.
I have this script that works nicely to extract a specific line from a file,
but it needs to run on every file that comes into the incoming folder and all
files have a different names but begin with "Order_Product_CD... and differ
by unique account id and a part number. ie.
Order_Product_CD_Request_ACCOUNTID_PARTNUMBER.txt The script is called with
a .bat and the output appends to a cds.txt file.
Does any one know how I can get this script to run on each file in the
incoming folder?
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile =
objFSO.OpenTextFile("\\Server\d$\cds\cd_request_load\incoming\Order_Product_CD_Request_ACCOUNTID_PARTNUMBER.txt", ForReading)
strTargetText = objFile.ReadAll
objFile.Close
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
Set objFile =
objFSO.OpenTextFile("\\Server\d$\cds\cd_request_load\incoming\FindValue.txt",
ForReading)
Do Until objFile.AtEndOfStream
strName = objFile.ReadLine
objRegEx.Pattern = ".{0,}" & strName & ".{0,}\r"
Set colMatches = objRegEx.Execute(strTargetText)
If colMatches.Count > 0 Then
For Each strMatch in colMatches
strText = strText & strMatch.Value
Next
End If
Loop
Wscript.Echo strText
Thanks for any help!!
Very Best Regards,
Margarita Morales
>
>Hello all,
>
>I'm having a problem, I want to run the below script on all files in a
>folder.
>I have this script that works nicely to extract a specific line from a file,
>but it needs to run on every file that comes into the incoming folder and all
>files have a different names but begin with "Order_Product_CD... and differ
>by unique account id and a part number. ie.
>Order_Product_CD_Request_ACCOUNTID_PARTNUMBER.txt The script is called with
>a .bat and the output appends to a cds.txt file.
>
<snip>
Wrong newsgroup, but:
If the script can accept the file name from the command line, then in
the batch file:
For %%f in (*.*) do call <script> %%f
or something close to that. :-)
--
ArarghMail901 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html
To reply by email, remove the extra stuff from the reply address.
In regards to your reply:
My .bat file indicates:
cscript //nologo collectFFID.vbs >> D:\MK\cd_request_load\incoming\cds.txt
to call the .vbs and the call appends records to the cds.txt file, however
the .vbs script is where the file name is indicated, so every time you want
to run the script, you have to change the file name in the script.
("\\Server\d$\cds\cd_request_load\incoming\Order_Product_CD_Request_ACCOUNTID_PARTNUMBER.txt", ForReading)
If I place, the line you suggested in my .bat file, what value would replace
the file name? I've tried to place \Ord*.txt in place of the file name,
but it errors with a message something like "unable to locate file...."
Thanks again for your help. Oh, what group should I had placed this
request in? Just so I know better next time. ;)
cheers!
Margarita
>Hi and thank you for your quick reply. Sorry for logging to the wrong
>group. it seem to be the best fit for what I know of vb thus far.
>
>In regards to your reply:
>My .bat file indicates:
>cscript //nologo collectFFID.vbs >> D:\MK\cd_request_load\incoming\cds.txt
>
>to call the .vbs and the call appends records to the cds.txt file, however
>the .vbs script is where the file name is indicated, so every time you want
>to run the script, you have to change the file name in the script.
>
>("\\Server\d$\cds\cd_request_load\incoming\Order_Product_CD_Request_ACCOUNTID_PARTNUMBER.txt", ForReading)
>
>If I place, the line you suggested in my .bat file, what value would replace
>the file name? I've tried to place \Ord*.txt in place of the file name,
>but it errors with a message something like "unable to locate file...."
Haven't a clue. Try the script reference for command line parameters.
>Thanks again for your help. Oh, what group should I had placed this
>request in? Just so I know better next time. ;)
One concerning batch files or vba. This one is for an old 16-bit
compiler.
I ended up using SQL instead of using vb. I set up a DTS package and used
the BCP utility to move the files from the directory folder into the db and
then query for the specific records from the load table. this also allowed me
to send a Acknowledgement email to the CD requestor after loading the order
into the CRM system.
Thanks once more, I really appreciate your efforts in helping me. :)
--
cheers
Margarita