Monday, March 30, 2009

Create an Output Directory Structure for Batch Processing

I originally created this procedure while at the Georgia Institute of Technology (Georgia Tech) Center for Geographic Information Systems. In response to the following ERDAS-L question:

Q: “I have a lot of ASTER 1A HDF images to import to the .img format using the batch tool. How does one send, by batch procedures, the bands from each HDF into a directory for each ASTER image? The directory must exist before the batch starts. How may I create the output directory inside the batch tool?”

A: This procedure assumes you have an existing directory structure and require an identical one in the output location.

Part A:
1. Open a DOS Command Window
2. Change to the appropriate directory
3. Use "dir" command as follows: dir *.hdf /b /s > file-list.txt
4. Open "file-list.txt" in MS Excel
5. Copy & Paste 1st Column into a 2nd column
6. Find & Replace all "\" with "/", in both columns
7. In the 2nd column, Find & Replace old directory path with new directory path
8. Insert new row at top
9. 1st Column = “Input”; 2nd Column = “Output”
10. Save as tab delimitated text file with "file-list.bls".
Part B:
Part B1:
1. Open original "file-list.txt" in Excel with "\" as delimiter. Insert 1st and 2nd Column
2. Put mkdir in 1st Column, leave 2nd Column empty
3. Delete the file name column
4. Find & Replace Directory Path Columns as needed
5. Save as text file "mkdir.bat"
Part B2:
1. Open "mkdir.bat" in Word
2. Find & Replace: ^t^t with " " (a single space)
3. Find & Replace: ^t with "\"
4. Save as tab-delimited text file as "mkdir.bat".
Part C:
1. Run "mkdir.bat" in DOS window.
Part D:
1. Start the batch tool. Select Modify commands automatically.
2. Change Output "Variable" to "User"
3. Open .bls in Batch tool in file list section
4. Launch program.

Wednesday, March 11, 2009