I try to keep a running log on all documents or folders that I am working on. What is nice about a batch file is that it provides a terse description just based on some commands in a text file. Because the date of the file changes, I can later use this to confirm what I was working on when I am ready to create a detailed timesheet. Mac and Windows both provide some simple tools to create simple to complex scripts. Well, Apple’s Mac uses a more sophisticated unix shell scripting and delivers a more thoughtful user experience. If your a Mac user stuck on a windows XP then you might not know how to batch a job.
Often I have a list of files needing some modification. Like tiff files missing tags or needing to be renamed.
you’ll need a good text editor, Notepad++ is what I use and it’s free. If your using this tool, just be sure you have the latest version with the “Extend” mode option. You will need this when searching and replacing.
You will need to click on Start->run and enter “cmd” then navigate to the folder or directory your files are in.
(It maybe a good idea to have explorer up to help you see what’s going on in nested folders.)
1) At the command prompt type:
dir /b *.tif > tiflist_runfirst.bat
the contents of the new file will look something like this:
f:\tif1.tif
f:\tif2.tif
f:\tif3.tif
2) in Notepad++, search and replace “f:\” with “set MYTIF=”
3) again in Notepad++ with mode “Extended” on, search and replace “.tif” with “.tif\ncall process_mytifs %MYTIF%”
set MYTIF=tif1.tif
call process_mytifs %MYTIF%
set MYTIF=tif2.tif
call process_mytifs %MYTIF%
set MYTIF=tif3.tif
call process_mytifs %MYTIF%
4) In your text edit tool, create and save in the same location process_mytifs.bat
your process in the .bat file is going to be whatever function your running along with remarks that explain what your doing at least. It should look something like this:
@echo off
rem ***** read a file from memory placed there by tiflist.bat
echo I am processing: %1
rem ***** the first time you run tiflist_runfirst.bat, test twice before doing a big batch job
rem <your function goes here> i.e.: geotifcp -g mygeotif.dat -e %1w %1 f:\mypath\geotiff\%1
rem **** put your function in place of the remark line above.
rem ***** I left an example of geotifcp comand line
@echo on
5) Now it’s time to run your batch job. Your first test should have all you see above and nothing after “echo I am processing: %1″
It’s not a good idea to try and run a function at this point.
In the command window, simply type “tiflist_runfirst”
You should see something like:
set MYTIF=tif1.tif
call process_mytifs tif1.tif
I am processing: tif1.tif
set MYTIF=tif2.tif
call process_mytifs tif2.tif
I am processing: tif2.tif
set MYTIF=tif3.tif
call process_mytifs tif3.tif
I am processing: tif3.tif
If you want, take off the remark the “@echo on” line to quite the app down.
6) next just use only a few files by copying from tiflist_runfirst.bat into another batch file tiflist_run_test.bat for example.
Then edit “process_mytifs.bat” by inserting your function with the file variables to be processed.
now type at the command prompt, “tiflist_run_test.bat” and check your output to make sure all is well.
That’s it.

Post a Comment