drag and drop multiple file on a bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mt_mt
Posts: 3
Joined: 01 May 2022 05:04

drag and drop multiple file on a bat file

#1 Post by mt_mt » 01 May 2022 05:12

Hi All,

I would like to ask some tips how to do this, trying to drag and drop mulitple files on a bat file that run a program.

My bat file is like this, so far it only will open two text files i drap and drop. What if i want to open ten or more text files? tried to google but just really can't get it work.

Thank you.


C:\Windows\notepad.exe %1
C:\Windows\notepad.exe %2

pause


Regards,
mt

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: drag and drop multiple file on a bat file

#2 Post by aGerman » 01 May 2022 12:36

Something about like that:

Code: Select all

@echo off &setlocal
for %%i in (%*) do start "" notepad %%i
Note that the batch code receives the whole path for each file. At some point (depending on the length of the path) you will exceed the maximum length of a command line if you drop too many files.

Steffen

mt_mt
Posts: 3
Joined: 01 May 2022 05:04

Re: drag and drop multiple file on a bat file

#3 Post by mt_mt » 01 May 2022 21:43

Hi Steffen,

Thank you able to make it work.

was trying to make a program (not notepad) to run multiple files by batch.

But i realize it will open and run the program same times together.

My silly way
C:\Windows\notepad.exe %1
C:\Windows\notepad.exe %2

will make the program run first file (%1) then second file (%2).

for %%i in (%*) do start "" notepad %%i

I can open two drag and drop files same time but if there is a way to make the program run drag and drop files one by one? ( as the program i intend to run is a render program that eat memories).

Thank you for your time.

Regards,
mt

mt_mt
Posts: 3
Joined: 01 May 2022 05:04

Re: drag and drop multiple file on a bat file

#4 Post by mt_mt » 01 May 2022 22:17

found the behaviour i would like it to be after i remove the "start"

c:
cd xxxxxx(directory where the program)

for %%i in (%*) do xxxxx(program exe file name) %%i

Thank you very much.

Regards,
mt

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: drag and drop multiple file on a bat file

#5 Post by aGerman » 02 May 2022 00:04

My bad, sorry. I added the START command because people usually ask for asynchronous processing of several files :lol:

Steffen

Post Reply