Solved

Shell script to batch convert ps files to pdf with ps2pdf

Posted on 2008-10-20
3
2,094 Views
Last Modified: 2013-12-06
As part of our DR/BC plan, our Linux-based application creates 100's of .ps Postscript files, but I need to convert these to PDF files.  I know the ps2pdf will do this for me, but I would like a cronjob script to automate this for me.

I have confirmed that ps2pdf works properly with manual operations, but I would like a script in a cron job to automate the converson.  

I have very limited linux scripting and mega experience with Windows vbscripting.  I could move these files to a Windows system, but I prefer to use Linux.

Something along this method of psuedocode:

for each $file in $dir{
ps2pdf $file $file.pdf
}


Any ideas?
Thanks!!
-Kevin
0
Comment
Question by:kevin_buchanan
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 total points
ID: 22764532
find /in/my/dir -type f -name "*.ps" | while read name
do
     fname=`basename $name`
     ps2pdf $name /my/pdf/dir/$fname.pdf
done
0
 
LVL 84

Expert Comment

by:ozo
ID: 22764536
#!/usr/bin/bash
for   file in $dir/*.ps ; do
ps2pdf $file $file.pdf
done
0
 
LVL 1

Author Closing Comment

by:kevin_buchanan
ID: 31508150
Thanks - that worked GREAT!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating a Samba server for a small office. Ubuntu Linux and Samba can breathe new life into a retired PC and save an office money on new hardware/software. Our example server will have two hard disks, one exclusively for storing shared data. …
After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now