Saved Bookmarks
| 1. |
Solve : Creating a batch file to run an application on an entire directory contents.? |
|
Answer» HI guys, Tried a bit of a search on this but lacking the DOS knowledge to search the right thing I expect. In brief, I use a command line app which does some image processing on a single image. (it produces a series of bump, normal and specular texture maps for use in GAMES) The app is called shadermap.exe and I can run the process on a single image with a batch file like the following: Code: [Select]START /WAIT shadermap.exe cdiff "d:\shadermapcommandline\mytestimage.tga" -disp (60,100,12,xy) -norm (100,200,xy,0) -ambo (100,10,10,35,25,0,xy) -spec (100,-50,52,xy) -v I have around 1500 images I need to run this procedure on, however. So I'm hoping someone can help out a DOS novice to create a variation of this batch file to just run the process on 'all' image files in a directory. (so I can just drag this bat and exe into any folder and click it to process all.) Much appreciate any help. Thanks! Here's a link to the app and test image if useful: http://www.fo0k.com/dump/shadermapcommandline.rarTry this Code: [Select]@echo off set ShaderMapParams=-disp (60,100,12,xy) -norm (100,200,xy,0) -ambo (100,10,10,35,25,0,xy) -spec (100,-50,52,xy) -v for %%A in (*.txt) do START /WAIT shadermap.exe cdiff "%%A" %ShaderMapParams% Sorry I absent mindedly pasted a testing version - here is the corrected version for %%A in (*.tga) do START /WAIT shadermap.exe cdiff "%%A" -disp (60,100,12,xy) -norm (100,200,xy,0) -ambo (100,10,10,35,25,0,xy) -spec (100,-50,52,xy) -v hah! fantastic. The one thing I would ask you is how to get it to save the newly generated images in the same folder? It seems that regardless of which folder I place the exe and bat file in.. when it generates the new images, it will just dump them in the root of the drive which is not ideal. (but not the end of the world..!) Many thanks for your help.I am not familiar with shadermap.exe, but I did a bit of Googling (there are forums specialising in that**) and from what I can gather, you may need to create an output folder, and run the batch from that folder, including in the batch the full path and name of the input files, so this might work... run it in the folder where the input tga files are... ** like here http://www.renderingsystems.com/support/showthread.php?tid=3 @echo off set thisfolder=%~dp0 rem edit these to suit set outputfolder=c:\shadermap-output set jobscriptname=myjob.bat if not exist "%outputfolder%" md "%outputfolder%" if exist "%outputfolder%\%jobscriptname%" del "%outputfolder%\%jobscriptname%" for %%A in (*.tga) do ECHO START /WAIT shadermap.exe cdiff "%%~dpnxA" -disp (60,100,12,xy) -norm (100,200,xy,0) -ambo (100,10,10,35,25,0,xy) -spec (100,-50,52,xy) -v >> "%outputfolder%\%jobscriptname%" echo Changing to output folder cd /d "%outputfolder%" echo STARTING job call "%jobscriptname%" echo Finished job echo Changing back to input folder cd /d "%thisfolder%" echo. pause This works like a charm. Thank you so much for your time. I had searched through the shadermap forums previously but there was no MENTION of a script to work like this. I think they would understandably want you to purchase the full version, which along with a lot more FUNCTIONALITY also includes batch jobs for multiple files. Therefore not so keen to advertise how to achieve this via CL on their site. Wouldn't it be good if you could buy someone a beer over the internet... like take a printout to your local pub for a free pint. If I could, I would! Thanks again , Salmon! |
|