MSFN Forum: Batch - execute epstopdf for all *.eps within folder - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch - execute epstopdf for all *.eps within folder execute epstopdf for all *.eps within folder Rate Topic: -----

#1 User is offline   cirrocumulus 

  • Group: Members
  • Posts: 3
  • Joined: 12-July 12
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 12 July 2012 - 02:45 AM

Hey there!

A question from me as a newbie in batch-programming :huh: :
I would like to program a batch-file which executes epstopdf.exe for every *.eps in the folder, where the batch-file is located.

A friend told me to use the following command-line interface (which does work pretty well, but is sometimes quite cumbersome):
for %i in (*.eps) do epstopdf %i


I'm sure someone can help me :)

Thanks in advance!


#2 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,433
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 12 July 2012 - 03:00 AM

View Postcirrocumulus, on 12 July 2012 - 02:45 AM, said:

A friend told me to use the following command-line interface (which does work pretty well, but is sometimes quite cumbersome):
for %i in (*.eps) do epstopdf %i


I'm sure someone can help me :)


Yep, at it's vey basic you need to:
  • make sure that the "right directory" is chosen
  • make sure that the epstopdf.exe program is found
  • translate that one-liner in a batch (basically doubling the % in the FOR loop variable


Basically:
@ECHO OFF
CD /D %~dp0
SET Program="C:\My program directory\eps to pdf\epstopdf.exe"
for %%A in (*.eps) do %Program% %%A

this assumes that you copy the small batch to the directory and that you have the program in a "fixed" directory, in the example "C:\My program directory\eps to pdf\epstopdf.exe".

The %~dp0 will expand to the drive and path of the item 0 of the command line (the batch file itself).

jaclaz

This post has been edited by jaclaz: 12 July 2012 - 03:01 AM


#3 User is offline   cirrocumulus 

  • Group: Members
  • Posts: 3
  • Joined: 12-July 12
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 12 July 2012 - 03:09 AM

@jaclaz: Amazing how fast you have given me this answer! :thumbup
Thank you very much for the great explanation.

I'll try it immediately!

cirrocumulus

#4 User is offline   dencorso 

  • Adiuvat plus qui nihil obstat
  • Group: Super Moderator
  • Posts: 4,866
  • Joined: 07-April 07
  • OS:98SE
  • Country: Country Flag

Posted 12 July 2012 - 03:04 PM

View Postjaclaz, on 12 July 2012 - 03:00 AM, said:

@ECHO OFF
CD /D %~dp0
SET Program="C:\My program directory\eps to pdf\epstopdf.exe"
for %%A in (*.eps) do %Program% %%A

this assumes that you copy the small batch to the directory and that you have the program in a "fixed" directory, in the example "C:\My program directory\eps to pdf\epstopdf.exe".

The %~dp0 will expand to the drive and path of the item 0 of the command line (the batch file itself).


Since there always is room for improvement, let me please suggest one:

@ECHO OFF
PUSHD %~dp0
SET Program="C:\My program directory\eps to pdf\epstopdf.exe"
for %%A in (*.eps) do %Program% %%A
POPD


The pair PUSHD/POPD saves the current drive:\directory, before changing to the new one, then returns to it, respectively.
So, at the end, you'll be back to the folder you started in.

#5 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,352
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 12 July 2012 - 06:30 PM

This is a VBS Script that will find EPS files anywhere on the Computer that this script
run from. Fill in the App = Chr(34) & "PATH_TO_APPLICATION_HERE" & Chr(34)
with the correct path to the app. The Chr(34) = ", so the app path will be in double quotes
 Dim Act :Set Act = CreateObject("Wscript.Shell")
 Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
 Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\cimv2")
 Dim App, Col, Obj
App = Chr(34) & "PATH_TO_APPLICATION_HERE" & Chr(34)
  Set Col = Wmi.ExecQuery _
  ("Select * from CIM_DataFile Where Extension = 'eps'")
'-> If No File Is Found
  If Col.count = 0 Then
   Act.Popup "Can Not Find This File Type : eps",5,"No File Found",4128
  Else
   For Each Obj In Col 
'-> Run Only If App Exists
    If Fso.FileExists(App) Then Act.Run(App & Obj.Name),1,True
   Next
  End If



#6 User is offline   cirrocumulus 

  • Group: Members
  • Posts: 3
  • Joined: 12-July 12
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 13 July 2012 - 12:10 AM

@dencorso & gunsmokingman:
Thanks for the additional informations!
I see, I'll have to learn a bit vbs- and batch-programming. Sometimes it seems to be really useful :)

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy