Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # Uses convert cmdline tool
  2. import os
  3.  
  4. def main():
  5. dir_list = os.listdir('./pdfs') # change to your pdf directory
  6. for full_file_name in dir_list:
  7. base_name, extension = os.path.splitext(full_file_name)
  8. if extension == '.pdf': # then .pdf file --> convert to image!
  9. cmd_str = ' '.join(['convert',
  10. '"./pdfs/' + full_file_name + '"', # change to your pdf directory
  11. '"' + base_name + '.png"'])
  12. print(cmd_str) # echo command to terminal
  13. os.system(cmd_str) # execute command
  14.  
  15. if __name__ == '__main__':
  16. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement