derekvan Posted November 29, 2023 Share Posted November 29, 2023 (edited) Hello, I am trying to create a File Action that takes user input. This is an action that takes the selected PDF file in finder and changes the page numbers of the file (e.g., the PDF is of an article that starts on page 36 and this action would make it so that the PDF file doesn't start on 1, but on 36). If I hard code in the page number, the action works great for me as a bash script: python3 -m pagelabels --delete "$1" python3 -m pagelabels --startpage 1 --firstpagenum 251 "$1" However, I need to have a way to prompt for user input to add the page number (here, number 251). How can I add this? (you might be wondering, why don't I turn this action into a python script instead of a bash script. The answer is, I have no python experience. I'm just using a thing I found on GitHub that I was able to get working on the command line.) Here's the action itself: https://www.dropbox.com/scl/fi/hp8vohuqihme58ancud8e/PDF-Page-Numbers.alfredworkflow?rlkey=4drl8iffe06uciinr8zbqu68a&dl=0 edit: here's the link to the python command: https://github.com/lovasoa/pagelabels-py Edited November 29, 2023 by derekvan added link to python command Link to comment
vitor Posted November 30, 2023 Share Posted November 30, 2023 First, use an Arg and Vars Utility right after the File Action, to save the PDF’s path to a variable, say file_path. Then add a Keyword Input to ask for the page number. Finally, in the Run Script change (both) "$1" to "${file_path}" and 251 to "${1}". Link to comment
derekvan Posted November 30, 2023 Author Share Posted November 30, 2023 Awesome! Thanks much for your help--that did it. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now