0

I've been trying to generate a custom action in Sourcetree that goes over a set of selected unstaged files and performs some function on them. My action is setup to use $REPO and $FILE which in the description says:

"$FILE: the path of the selected file(s) within the repository"

I'm running the action through a .bat file which looks something like this:

@echo off

call "<python path>" "...\myFile.py" --repo=%1 --file=%2

Then the python script should run all my important logic.

My issue is that when I select multiple files in Sourcetree and run the action, only one of them is passed into the batch file. How do I make it so I get all the selected files and not only one?

torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

0

Not very familiar with batch or how command line arguments come in. After a bit of trial and error discovered that the arguments come in as %1, %2, %3, etc. Using %* would give me all of them.

Then did some extra research to get everything after %1 and found this: batch parameters: everything after %1

So inside of the batch file I added this

set _tail=%*
call set _tail=%%_tail:*%1=%%

Then, I passed %tail% into --file and that seems to work. I guess I could also just get all of them with %* and split them up in the python side-- this is fine for now.