tags:

views:

49

answers:

1

example 1

@echo off  
for %%a in (precomp.exe) do set pc=%%~fa  
for /r %%a in (*.pcf) do (  
  pushd %%~dpa  
  echo [%pc% -r %%~nxa]  
  %pc% -r %%~nxa 
  popd 
)

When i run the bat i get precomp.exe is an unknown command I have precomp in the folder with the script. But it will only work if i copy precompt to every sub directory and every folder that contains a .pcf file

Tried a different approach using 2 scripts

script1   

for /r %%i in (*.pcf) do call sr2 "%%~pi" "%%i"   
script 2  
pushd %1                 
precomp -r %2    
popd        

Both scripts work but only if i copy precomp into Ever folder and all sub folders. Please help as i know there must be away to make the script use the precomp in the folder with the script

A: 

You can temporarily modify the PATH environment variable to include the path of precomp:

e.g.:

setlocal
set PATH=%PATH%;%~dp0
for /r %%i in (*.pcf) do (
    pushd "%%~pi"
    precomp -r %%i
    popd
)

or use the path of precomp directly:

for /r %%i in (*.pcf) do %~dp0\precomp -r %%i
Joey
Almost worked your first solution, but alas it doesnt :( seems like precomp relies on a dll in the same folder as the script and precomp.But when i run the script im getting could not determine file size.Ill keep trying though :) Thanks for your help though. one step closer
kam
Hm, DLLs should be picked up from the same directory where the exe resides (and the PATH as well) and not the current working directory. Also is the current working directory important? Because the second approach doesn't change it and should therefore work as is.
Joey
I cant set the Working directory as an absolute Path, as this will change according to the End user`s install preference ill fiddle around with your second solution, but when i ran it the bat just exited . ill have another look thanks for your help joey
kam
@kam: If `precomp` is itself a batch file, you will need to use `call precomp`. Otherwise it won't return to the caller.
Joey
Joey thanks again for your help, No precomp is a small command line program. Could i use a Set PATH=%D% where %D is current directory? Ive never been sure on how to use the Set local; Set path command,ill look into it
kam
@kam: You can use the `%CD%` pseudo-variable for the current directory.
Joey
:) thanks Joey ill put that in my book and try it out.You took the time to help me out. A class act :) cheers mate
kam