Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell script to change .pdf files to .png Mac OS 10.3

I'd like to make a script on Mac OS 10.3 that converts a pdf to a png. I've been looking around but I'm not sure if its even possible. I keep reading about a "sips" command but it doesn't seem to be available on 10.3, or at least this one. I typed man sips in the terminal and nothing came out. I have written a couple bash scripts and kind of understand how they work but was hoping this specific issue at work would be a good way to practice. I could probably write something that changes the name, but I'm not sure that would work in and of itself as the new png file would probably not actually work. Is there a way from the terminal to basically open preview, open each file and then save as a png? that would probably be the best option. Thanks

like image 870
Dave2081 Avatar asked Jun 14 '11 20:06

Dave2081


People also ask

How do I convert a PDF to a PNG in Linux terminal?

When the PDF file is successfully imported, go to the "File" tab and choose "Export To" from the drop-down list. Under the "Export To" drop-down menu, select the "Image" format to access a list of supported image formats. Locate and select the "PNG” option from the list.


1 Answers

Use the following shell script.

  1. Make bash file e.g., test.bash

for i in *.pdf; do name=$i; name=${name%.*}; sips -s format png $i --out ${name}.png; done

  1. Enter the command

bash test.bash

like image 93
KyungHoon Kim Avatar answered Sep 30 '22 01:09

KyungHoon Kim