Advertisement
clockworkpc

Zenity folder selector for PDFgrep in Ubuntu

Aug 27th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. #!/usr/bin/python
  2. #/home/clockworkpc/bin/pdfsearch.py
  3.  
  4. # Released under a GPLv3 Licence by Clockwork PC 2012
  5. # www.clockworkpc.com.au
  6.  
  7. # You are entitled to the following four freedoms:
  8. # Freedom 0: To run this program for any purpose
  9. # Freedom 1: To study how this program works and change it to make it do what you wish
  10. # Freedom 2: To redistribute copies so you can help your neighbour
  11. # Freedom 3: To distribute copies of your modified version to others
  12.  
  13. import os
  14. import subprocess
  15.  
  16. #Get folder using Zenity GUI
  17. proc = subprocess.Popen('zenity --file-selection', shell=True, stdout=subprocess.PIPE, )
  18. output = proc.communicate()[0].strip()
  19. searchFolder = output + "/*.pdf"
  20.  
  21. #Define the search term  and prepare the Shell command for the commandline application pdfgrep
  22. searchTerm = raw_input("What is the search term? ")
  23. searchPrefix = "pdfgrep -i -H -n "
  24. searchCMD = searchPrefix + '"' + searchTerm + '" ' + searchFolder
  25. print searchCMD
  26.  
  27. #Execute pdfgrep
  28. os.system(searchCMD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement