tags:

views:

833

answers:

2

I have an exe that I can drag and drop another file onto to produce a third file. Unfortunately it seems to accept only 1 file at a time, if I select multiple and drop it doesn't seem to work.

How do I create a batch file to automate the process of dragging a thousand files of .drag extension onto drop.exe?

Thanks!

+1  A: 

In Windows, dropping a file on an exe just executes the command line:

fileprocessor.exe "<full path to dropped file>"

So you should be able to just call the exe directly in your batch file, passing the path to each file that you'd like to process.

EDIT: Look into the For batch command to do this for a series of files. You should be able to specify the wildcard and then call the command for each.

For %%a in (*.drag) do fileprocessor.exe "%%~fa"
dmercredi
oh wow I do not want to write 1000 paths. shouldn't I be able to do a wildcard? Such as all .drag files in this folder?
Jourkey
+1  A: 

Evidently, batch files can have multiple objects dropped onto them. See this question. You should be able to adapt the answer to your needs. I do wonder if there is a maximum number of characters that can be passed in, though, so you might not be able to drag thousands of files onto it. Possibly not even hundreds. But definitely multiple.

EDIT: In your comment to dmercredi's answer, you mention wildcards. If you don't need the drag/drop capability and just want to specify *.drag in your batch file, check out this question instead. There are a variety of answers there that may suit your needs.

John Y
There is a maximum command-line length for cmd. 8191 characters.
Joey