Hello,
i wanted to ask how i can drop files into an Batch File. So i drop two files and the first file has the variable %variable1% and the second %variable2% . How do i do that? I saw that this is pssobile, so can anyone post a code for me? :/
Drag and drop files into batch file
Moderator: DosItHelp
Re: Drag and drop files into batch file
You can access "drag and dropped" files using the command line accessors (%0, ... %9, %* - if using more than 9 arguments you may use the "shift" command):
Result (drag and drop two files named "no_space.txt" and "with space.txt":
(If you wnat to execute these files, then you could call them using "call "%~1"", or "call "%~2"" without the outer doublequotes.)
penpen
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
echo Command line: %0 %*
echo Command line argument 1: "%~1"
echo Command line argument 2: "%~2"
pause
endlocal
goto :eof
Result (drag and drop two files named "no_space.txt" and "with space.txt":
Code: Select all
Command line: "Z:\test.bat" Z:\no_space.txt "Z:\with space.txt"
Command line argument 1: "Z:\no_space.txt"
Command line argument 2: "Z:\with space.txt"
Drücken Sie eine beliebige Taste . . .
penpen
Re: Drag and drop files into batch file
Neat! I didn't think this was possible.