Scripting Blog [archived]

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

How Can I Read the Contents of a Text File and Then Declare the Contents as Variables?

(image) Hey, Scripting Guy! How can I read the contents of a text file, and then declare those contents as variables?-- TC(image) (image) (image) Hey, TC. Before we begin, did you really ask us this question? We’re positive that you did, but, the way things have been going lately, we can’t be too sure. For example, by now everyone has ...

How Can I Locate a Word in a Text File and Then Echo Back That Word and Any Remaining Text?

(image) Hey, Scripting Guy! How can I search for a word in a text file and then, after I find it, echo back that word and any remaining text in the text file?-- KA(image) (image) (image) Hey, KA. Before we begin we’d like to thank the hundreds and hundreds of people who have sent Scripting Guy Jean Ross get well wishes after her ...

How Can I Search a Text File for Strings Meeting a Specified Pattern?

(image) Hey, Scripting Guy! How can I search a text file of product IDs and retrieve just those lines that meet a specified pattern?-- WT(image) (image) (image) Hey, WT. Before we get to today’s question we were wondering if anyone else has seen the commercial for the car that features the all-new “heartbeat sensor?” The idea is that...

How Can I Modify a Text File and Then Extract Selected Lines From the Modified Contents?

(image) Hey, Scripting Guy! How can I write a script that modifies the contents of a text file and then copies specified lines from the modified contents to a new file?-- EH(image) (image) (image) Hey, EH. There’s no way to do that. Now go away and leave us alone. Wait, sorry; we didn’t mean it. As it turns out, the Scripting Guy who ...