I want to drag and drop a file onto a batch file in order to run the below command on it. How do I go about running the command on the dropped file?
PotreeConverter.exe <dropped file> -o C:/output -p index
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
You are able to prompt a user for input using a Batch script function.
The path
of the file, when you drop it on the BAT
file, will be returned as a normal %1
argument.
so :
@echo off
PotreeConverter.exe "%~1" -o C:/output -p index
You can use %*
if you drop more then 1 file
Example :
@echo off
for %%a in (%*) do echo [%%a] was dropped on me
pause
Following this easy guide.
Create a batch file test.bat
with the contents
@echo off
echo The full path of the file is: %1
pause
Drag any file onto it, you will see that %1
is replaced with the full path for that file in quotes.
Now you know how to execute some command that takes a path to a file as an argument:
@echo off
some_command_that_takes_a_path_to_a_file %1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With