jsutter
October 19, 2013, 10:26pm
1
In a directory Base, I have 01-09.map files. I wish to batch a common change in each and end up with 2 folders, Base and Base-changed.
Map files can be read as text by changing .map to .txt. These files are readable but cannot be edited.
For example, 09.map
Time 310
ColorCount 5
Colors 1 2 5 6 7
Field 8x10
— --- c1 x5 x6 c1 — ---
w1 w1 c1 c1 c1 c1 w1 w1
w1 w1 c1 a28 c1 c1 w1 w1
w1 w1 c1 c1 a29 x2 w1 w1
w1 w1 c1 c1 c1 c1 w1 w1
w1 w1 x5 c1 c1 x2 w1 w1
w1 w1 c1 c1 c1 c1 w1 w1
w1 w1 c1 c1 c1 a30 w1 w1
w1 w1 x5 c1 c1 x7 w1 w1
— --- x7 b8 c1 x5 — ---
I want to change the Time values in all to 6000. Some macro batcher?
Aloha
Mithras
October 19, 2013, 11:42pm
2
This isn’t the most extensible piece of code, but it should do exactly what you described. You just need to change the input and output directories. Save the following to a file with an extension of ‘vbs’ and run it by typing:
cscript yourfile.vbs
For i = 1 to 9
Set fileSys = CreateObject(“Scripting.FileSystemObject”)
Set inFile = fileSys.OpenTextFile(“C:\input_directory\0” + CStr(i) + “.map”)
Set outFile = fileSys.CreateTextFile(“C:\output_directory\0” + CStr(i) + “.map”)
Do Until inFile.AtEndOfStream
line = inFile.ReadLine
If InStr(line,“Time”)> 0 Then
line = “Time 6000”
End If
outFile.WriteLine(line)
Loop
inFile.Close
outFile.Close
Next
Stay tuned. Mahalo and Aloha
Like a charm. Looks pretty extensible to me. Thanks so much. Aloha