The point is that you don??™t always have to use a scripting
object; sometimes a command line tool works just as well or even better.
The code now has two files to work with. The first is an input file, TmpDirFiles.TXT, which contains
the list of temporary files. The second is an output file, Output2.CSV, which contains the database
of file entries. The FSO.OpenTextFile() constant of 8 opens the file in append (read/write)
mode. If the file doesn??™t exist, the code raises an error unless you also set the third argument to True,
which tells the method to create the file when it doesn??™t exist.
Now all the code needs to do is process the data and output it. The user and computer names are
straightforward. Processing the date requires the most code because the code has to put the date
string together. The downside of all this code is that it makes the example harder to read than the
batch file. The plus side is that you can create a date string in any format required, even nonstandard
formats.
As a final note on this example, make sure you close files when you finish working with them.
Otherwise, the script raises an error when you try to open the file again.
Pages:
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485