0

I am new to using command prompt. I have a large amount of zip files I need to run a program on.

Running the program on one of the files in the command prompt looks like this:

Tabulate.exe -i S:\Packages\ZipFolderName_1.zip -o S:\Output\ZipFolderName_1

which spits out a csv.

I have found these posts helpful, but cannot seem to implement for my situation:

Iterate all files in a directory using a 'for' loop

Loop on files and run command

petezurich
  • 9,280
  • 9
  • 43
  • 57
alexb523
  • 718
  • 2
  • 9
  • 26

1 Answers1

0

Read entire for /? output, pay your attention to ~ modifiers. In the following cmd compound command is used ECHO to merely show Tabulate.exe lines to be executed:

for %I in ("S:\Packages\*.zip") do @ECHO Tabulate.exe -i %~fI -o S:\Output\%~nI

To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.

@ECHO OFF
SETLOCAL EnableExtensions

for %%I in ("S:\Packages\*.zip") do (
    rem explaining comments:
    rem %~fI expands %I to a fully qualified path name
    rem %~nI expands %I to a file name only  ↓↓↓↓
    ECHO Tabulate.exe -i %%~fI -o S:\Output\%%~nI
rem ↑↑↑↑ remove `ECHO` no sooner than debugged  
)
JosefZ
  • 28,460
  • 5
  • 44
  • 83