0

I am launching an application with parameters in this way:

application.exe /in:"c:folder\filename1.txt" --log
application.exe /in:"c:folder\filename2.txt" --log

And that runs the first instance, waits for it to finish and then runs the second.

How can I programmatically run all the files within 'folder' in alphabetic order (Keeping the same "wait and go" logic) ?

Thanks in advance

Attila
  • 702
  • 1
  • 12
  • 34
  • From the command line: `for %f in (c:folder\*.*) do application.exe /in:"%f" --log` – Aacini Aug 26 '15 at 14:54
  • An NTFS formatted drive sorts by alphabet naturally but a FAT32 formatted drive needs to have a sort option specified. – foxidrive Aug 27 '15 at 08:10

2 Answers2

1

This script will launch all the applications in the current directory (in alphabetic order), wait for them to finish and then continue to the next one (%%a in a batch file and %a in cmd)

for /f %%a in ('dir /B /O:N^|findstr /L /I ".exe"') do ("%%a" /in:"c:folder\filename1.txt" --log)
Sam Denty
  • 3,693
  • 3
  • 30
  • 43
1

I use powershell and have used the below bit of code. It will loop through each script matching a pattern and will execute alphabetically. In this example we'll execute any powershell script:

Get-ChildItem "C:\Scripts" | Where `
    { $_.Name -like '*.ps1'} | ForEach `
    { . $_.FullName }

If you wanted to launch batch scripts you can do something like this:

Get-ChildItem "C:\Scripts" | Where `
    { $_.Name -like '*.bat'} | ForEach `
    { cmd.exe /c $_.FullName }
RLC
  • 21
  • 3