I have a Pyhton script.
I need to be able to select many files in explorer (I assume it's called explorer?)...
And then call the script and pass the full file names to the script.
Full = give full path.
So when the code runs, this is what get's run:
myscript.py "/home/My User/My Sub Folder/abc.txt" "/home/My User/My Sub Folder/pqr.txt" "/home/My User/My Sub Folder/xyz.txt" "/home/My User/My Sub Folder/123.txt"
I put quotes around the names as there will be spaces in folder or file names.
How can I do this?
In Windows, i have a DOS script that I put in the SendTo folde. Then I can select files, right click and choose the file from the SendTo drop down.
It's more of a hack than anything. Ideally I would want to have be part of the Windows right click menu in explorer.
Thanks.
How to select many files and pass to a Python script
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
How to select many files and pass to a Python script
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How to select many files and pass to a Python script
How to do this likely depends on which file manager (or "explorer" using the name Windows gives to it) you're using. Which edition of Linux Mint do you have? Cinnamon, MATE or Xfce? If you're unsure see if you have System Info in your menu where you should be able to find it. Else open the terminal from your menu and run the command
inxi -S
to find it.Re: How to select many files and pass to a Python script
You could probably do all this in python (and it might be simpler) or write a bash script that does something along the lines of:
cd to your folder
ls to get all files > some_variable
parse some_variable to put the list into one or more variables in the format required
execute your python script with myscript.py $variable_containing_filenames.
cd to your folder
ls to get all files > some_variable
parse some_variable to put the list into one or more variables in the format required
execute your python script with myscript.py $variable_containing_filenames.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Re: How to select many files and pass to a Python script
That's a very convoluted way to run
./myscript *
Your shell will expand the glob and pass all matching files as a separate arguments to the script.
Re: How to select many files and pass to a Python script
Create a launcher pointing to your script, make sure to include %F or %U at the end of the command, then drag & drop onto the launcher.
Re: How to select many files and pass to a Python script
I only use bash when I have toThat's a very convoluted way to run
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Re: How to select many files and pass to a Python script
Python sounds great...
Is there code that allows me to say "act on selected files"?
I'll find the answer to that if there is.
The other thing is... how would I insert into the right click menu?
Would this involve having 2 windows. And dragging the files from one to the next?
Thanks.
Is there code that allows me to say "act on selected files"?
I'll find the answer to that if there is.
The other thing is... how would I insert into the right click menu?
Can you tell me a bit more about making a launcher? I couldn't find any links for this.
Would this involve having 2 windows. And dragging the files from one to the next?
Thanks.
Re: How to select many files and pass to a Python script
@gm10
cheeky
i didn't know it was common knowledge.
thanks
cheeky
i didn't know it was common knowledge.
thanks