In a recent blog post, I described how I use my iPad to grade history papers, but expressed frustration with my workflow for adding a grading rubric to each paper as I graded it. In response, @cliotropic suggested that I write a workflow using Automator on my Mac to append the rubric to the files before I pass them to the iPad. I was able to write an Automator workflow that adds the rubric to an individual PDF file, but it gives the new file a random name and requires me to run each file through the workflow individually--not ideal. What I need is something like what's described in this MacWorld forum post, but since I know next to nothing about python or scripting, that process is Greek to me. Can someone help translate that MacWorld post, or help me find a workaround? I suspect many humanities graders could benefit. (I realize that one workaround is to have students append the rubric themselves--but I'm trying to minimize the tech on their hand, which is creating more tech on my end than I can handle by myself!)
How do I use a script to append a grading rubric PDF to papers to be graded?
(4 posts) (2 voices)-
Posted 5 years ago Permalink
-
If I read this correctly, you're wanting to attach a PDF to the end of an arbitrary number of PDFs (in the same directory?).
Essentially the script from macworld takes a couple of arguments, the file to prepend, and an arbitrary number of files to attach that file to. It then passes it off to the Automater join script with a few options (creates a new file with '-joined' in the name).
I created a quick gist that essentially does the same thing in Ruby with the option parser that you can get at https://gist.github.com/886814. Essentially you can copy the contents in to a file named 'append.rb' somewhere on your computer. In my test, the directory layout is like this:
course_name/append.rb
course_name/pdf_files/
course_name/rubric.pdfInside of course_name, you would run a command like this:
ruby append.rb -a rubric.pdf pdf_files/*.pdf
This will create a new directory (output by default) and place all the combined files in there (it also opens the directory when the script finishes).
If you want to see more stuff going on, you can run this with a -v flag
ruby append.rb -v -a rubric.pdf pdf_files/*.pdf
This is a little more verbose than the shell version, and can hopefully get you going in the right direction to tailor this to do what you're needing.
HTH,
Wayne
PS. This will only work on a Mac
Posted 5 years ago Permalink -
Thanks! That works! If I wanted to add a text string to the filenames of the newly created files (for example, "R" to let me know the rubric is attached, or "PP2" to let me know the name of the assignment), where would I modify the script? I'm assuming line 52 or 55, but I don't know the code to add.
Posted 5 years ago Permalink -
So file names are a little weird. Essentially you'll need to change the line with fname = File.basename(f). There are additional parameters that will let you easily drop the file extension.
fname = File.basename(f, '.pdf')
This will create a string of just the file name (without the pdf extension on it). All you need to do then is append the code to that string with the file extension:
fname = fname + "-R.pdf"
Essentially you're amending one line and adding the second to the script. Bonus points if you add this in as a configurable option :)
Posted 5 years ago Permalink
Reply
You must log in to post.