Jump to content

Recommended Posts

Posted

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!


Posted (edited)

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:

  1. make sure that the "right directory" is chosen
  2. make sure that the epstopdf.exe program is found
  3. 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

Edited by jaclaz
Posted

@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

Posted

@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.

Posted

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

Posted

@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 :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...