batch-filecmd

Run command with drag and drop onto batch file


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

Solution

  • The path of the file, when you drop it on the BATfile, 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 than one file

    Example that handles several files:

    @echo off
    
    for %%a in (%*) do echo [%%a] was dropped on me 
    pause