Batch script to pass all files in directory and execute the vbs script
Posted: 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)"
}
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)"
}