Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

How Can I Add Leading Zeroes to All the Lines in a Text File?

(image) Hey, Scripting Guy! I have a text file where each line is a set of characters like this: 56A63, 78A41, etc. I need to put leading zeroes in front of these strings in order to make them all nine characters long: 000056A63, 000078A41, etc. Oh: and my text file has 20,000 lines that need to be modified like this. How can I do all that ...

How Can I Get a Script to Delete Itself?

(image) Hey, Scripting Guy! I have a script for installing a printer that I give to my end users. When the script finishes, I’d like it to be able to delete itself. How can I get a script to delete itself?-- EA(image) (image) (image) Hey, EA. You know, that’s an interesting idea: disposable scripts, just like disposable razors or ...

How Can I Rename Files Using File Names I’ve Written to a Text File?

(image) Hey, Scripting Guy! I have a bunch of files with names like 001.jpg and 002.jpg. I also have a text file that includes the names I would like each of these files to have; for example, 001.jpg should be named Picture_of_Family_Members.jpg. How can I write a script that reads information from the text file and then renames each picture...

How Can I Query a Text File and Retrieve Records That Occurred on a Specific Date?

(image) Hey, Scripting Guy! We have tons of text files in which each line in the file represents a record or an event of some kind. How can I use a script to retrieve records or events that occurred on a specified date?-- TW(image) (image) (image) Hey, TW. You know, in your email you sort of apologized for using text files, noting that “...

How Can I Select a Column of Data in Excel and Then Paste that Data into a Text File?

(image) Hey, Scripting Guy! How can I select a column of data in Excel and then paste that data into a text file?-- GT(image) (image) (image) Hey, RR. You know, if you’re like most people, any time you hear the words “Scripting Guys” you undoubtedly think of two things: elegance and sophistication. Despite our well-deserved ...