Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Shell script to batch convert ps files to pdf with ps2pdf

Posted on 2008-10-20
3
Medium Priority
?
2,192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order for businesses to be compliant with certain information security laws in some countries, you need to be able to prove that a user (which user it was becomes important to the business to take action against the user after an event has occurr…
Are you sitting there reading this and wondering how to get started with Linux? It almost seems like picking the right Linux distribution is about like picking the right college or buying a new car if you read some of the article out there. Relax… l…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

664 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