Batch script to pass all files in directory and execute the vbs script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bhas85
Posts: 8
Joined: 27 Nov 2014 13:55

Batch script to pass all files in directory and execute the vbs script

#1 Post by bhas85 » 09 Feb 2023 02:04

My requirement is: In a dir i have text files. I need to pass the files names to the vbs script.

From command prompt i am passing each file like below. Now my requirement is to pass all files in directory through the script. Sometimes i will get filenames with spaces as well 2023-02-03- 15474.txt.Need to remove spaces and process the .txt files. I tried with below script. but the below script didn't worked. getting error as "filelist" doesn't exist, Please kindly someone help me with the batch script.

Below is the manual way i will run the vbs script.
c:\Programs\FT\FTMain\cmd>send.vbs ft=SEND_FF appli=Root flow=NLP12 filename=p:\prog\2023-02-03-15474.txt


$FileList = Get-ChildItem -Path "path of the files"

If ($FileList.count -gt '0')

{

foreach ($SingleFile in $FileList) {

& send.vbs ft=SEND_FF appli=Root flow=NLP12 filename=$SingleFile

}
}

else {

Write-Output "File doesn't exist..."

}
}


catch {

Write-Output "Something wrong happened while getting files"
Write-Output "Error is $($Error[0].exception.message)"

}

Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

Re: Batch script to pass all files in directory and execute the vbs script

#2 Post by Hackoo » 09 Feb 2023 10:39

Where is the vbscript code ? I saw a Powershell script ?
Please try to format your code and explain more your aim

bhas85
Posts: 8
Joined: 27 Nov 2014 13:55

Re: Batch script to pass all files in directory and execute the vbs script

#3 Post by bhas85 » 09 Feb 2023 11:38

Hi Hackoo

My requirement is to pass files from P:\prog\*.txt as a parameter at filename which is high lighted with the script. Please let me know if i am not clear with my requirement.

Running the command manually from command prompt temporarily

C:\Programs\FT\FTMain\cmd>send.vbs ft=SEND_FF appli=Root flow=NLP12 filename=p:\prog\2023-02-03-15474.txt

Script

Code: Select all

@echo off
set filelocation = "P:\prog\"
set vbscript = "c:\programs\FT\FTMain\cmd\send.vbs"
for /f "tokens=*" %%f in ('dir /b %filelocation%') do (
 call %vbscript% ft=SEND_FF appli-Root flow=NLP12783 filename="%%f"
)

Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

Re: Batch script to pass all files in directory and execute the vbs script

#4 Post by Hackoo » 09 Feb 2023 13:00

And the source code of send.vbs where is it ?

Post Reply