Browse by Tags

Tagged Content List
  • Blog Post: Hey, Scripting Guy! How Can I Extract All the Text Between Two Tags in a Text File?

    Hey, Scripting Guy! I have a whole bunch of text files in a folder. I need to open each of these files, extract everything between the <filecount> and </filecount> tags, and then write that information to a separate file. How can I do that? -- RP Hey, RP. You know, the other day the Scripting...
  • Blog Post: How Can I Number the Lines in a Text File?

    Hey, Scripting Guy! How can I number the lines in a text file? -- AS Hey, AS. You know, after being on vacation for three weeks the Scripting Guy who writes this column has a lot of catching up to do. In turn, that means that you have a lot of catching up to do. For example, did you know that the...
  • Blog Post: How Can I Extract Text Embedded Between Target Phrases in a Text File?

    Hey, Scripting Guy! How can I read a text file until I encounter a specified phrase, then write that information to a new text file? I then need to repeat this process, reading the text file to the next instance of the phrase and then writing that information to another new file. And so on. -- EW ...
  • Blog Post: How Can I Get a List of All the PDF Files in a Folder and Its Subfolders?

    Hey, Scripting Guy! How can I get a list of all the .PDF files (only the file names; I don’t want the file path or file extension) in a folder and its subfolders, and then put that list into a text file? -- PS Hey, PS. You know, PS, this is actually a hard question; far harder and far more complicated...
  • Blog Post: Hey, Scripting Guy! How Can I Remove Unwanted Tabs From a Text File?

    Hey, scripting Guy! I have about 5,000 text files that have unwanted tabs at the end of each line. How can I write a script that removes these unwanted tabs? -- TT Note . If this looks – and sounds – a little different than the typical Hey, Scripting Guy! column, well, there’s a good...
  • Blog Post: How Can I Locate a Value in a Text File and Then Parse the Line of Text Where the Value Was Found?

    Hey, Scripting Guy! How can I open a CSV file, locate a value in column 1, then store the value in column 2 in a variable? -- THvdH Hey, HvdH. We have to be honest with you, it’s a little difficult for the Scripting Guy who writes this column to stay focused on his work today. After all, tomorrow...
  • Blog Post: How Can I Sort the Contents of a Text File?

    Hey, Scripting Guy! I have a text file that contains a list of computer names. How can I sort that file alphabetically? -- LR Hey, LR. If we wanted to take the easy way out we’d just tell you, “Sorry, you can’t do that.” And we could get away with that because none of Microsoft’s scripting technologies...
  • Blog Post: Hey, Scripting Guy! How Can I Conditionally Add Lines to a Text File?

    Hey, Scripting Guy! I need a script that can read a file and, based on the contents, insert some additional lines of text into that file. Can you help me with that? -- JS Hey, JS. We’re sure that most of you have heard by now that Microsoft has made an offer to buy Yahoo ! , an offer currently valued...
  • Blog Post: Hey, Scripting Guy! Quick-Hits Friday: The Scripting Guys Respond to a Bunch of Questions

    How Can I Automatically Open and Monitor Web Sites? Hey, Scripting Guy! I enjoyed reading your Quick-Hits Friday article that talked about opening multiple Web sites in different browser tabs, and that got me thinking. Our company has a number of Web sites we need to monitor, and I was wondering...
  • Blog Post: How Can I Make Sure That No Line in a Text File Exceeds 261 Characters?

    Hey, Scripting Guy! How can I make sure that no row in a text file exceeds 261 characters? -- RK Hey, RK. You know, this was a good day to ask a question; for once the Scripting Guy who writes this column is in an OK mood. (No, he’s never in a good mood, at least not when he’s at work.) Yesterday...
  • Blog Post: Hey, Scripting Guy! How Can I Write a Message to All the Empty Files in a Folder?

    Hey, Scripting Guy! I need to search a certain directory for files with a size of 0 KB, then replace the non-existent text in those files with an error message like this one: "File did not save correctly." I have been searching for the answer myself and can't seem to grasp it. Can you help me on this...
  • Blog Post: How Can I Search for Two Items in a Text File?

    Hey, Scripting Guy! You’ve shown us how to search a text file for a single word or phrase, but how can I search a text file for two phrases? I need to know if a file contains either Windows 2000 or Windows XP . -- JR Hey, JR. You know, it’s hard enough to get the Scripting Guys to do one thing; getting...
  • Blog Post: How Can I Eliminate Duplicate Names in a Text File?

    Hey, Scripting Guy! I have a text file that contains a bunch of names. How can I read through that text file and eliminate all the duplicate names? -- MW Hey, MW. We’re assuming you have a text file that looks something like this: Ken Myer Dean Tsaltas Jonathan Haas Ken Myer Dean Tsaltas Syed...
  • Blog Post: How Can I Tally Up All the Words Found in a Text File?

    Hey, Scripting Guy! While browsing the Internet I found a script that showed me how to get a list of all the unique words in a text file. That’s useful, but I’d like to go one step further: how can I determine the number of times each of those words occurs?? -- TZ Hey, TZ. As it turns out, that’s...
  • Blog Post: 2010 Scripting Games: Advanced Event 3--Creating Text Files for Class Note-Taking

    Note : We are no longer accepting entries for this event. See the due dates page for a list of all event due dates. About This Event Division Advanced Date of Event April 28, 2010 Due Date May 5, 2010 Event Scenario You need to create...
  • Blog Post: How Can I Replace Selected Lines in an XML File?

    Hey, Scripting Guy! How can I read lines 56 to 62 in one XML file, and replace those with lines 56 to 62 taken from another XML file? -- JA Hey, JA. First of all, we’d like to thank you for your question; in addition, we’d like to welcome you and everyone else to today’s Open House in honor of the...
  • Blog Post: How Can I Search a Text File for 9-Digit Numbers?

    Hey, Scripting Guy! How can I search for user names in a text file? In my case, the user names all consist of 9 digits, although they can be any 9 digits. -- GG Hey, GG. Interesting question. You want to search for 9-digit numbers (like 123456789) in a text file; the only problem is that these could...
  • Blog Post: How Can I Remove Any Line in a Text File That Contains a Specified String Value?

    Hey, Scripting Guy! How can I remove any line in a text file that contains the string f0 ? -- CJ Hey, CJ. Before we begin, we have a question for you : are you by any chance a serious player of online video games like EverQuest or World of Warcraft? Admittedly, none of the Scripting Guys play these...
  • Blog Post: Can I Read an Entire Text File Rather Than Reading It Line-by-Line?

    Hey, Scripting Guy! Right now I use a script to open a text file containing computer names. The script reads the first line of the file and connects to that computer, then reads the second line of the file and connects to that computer. Is there a way to store those names in a variable or something,...
  • Blog Post: How Can I Extract Information Located Between Two Known Values in a Text File?

    Hey, Scripting Guy! In a text file, how can I extract the information that appears between the string HOSTNAME= and a blank space? -- B Hey, B. You’ll have to pardon us if we seem a little sluggish today; we’re still recovering from all the fun and excitement of Windows PowerShell Week. What if you...
  • Blog Post: How Can I Concatenate Files of the Same Name?

    Hey, Scripting Guy! How can I concatenate all the files (taken from various folders) that have the same file name? -- AS Hey, AS. You know, the hardest part about selecting questions to be used in the Hey, Scripting Guy! column isn’t writing the scripts; instead, it’s figuring out how to go about...
  • Blog Post: Hey, Scripting Guy! How Can I Read the MAC Address From a Text File?

    Hey, Scripting Guy! I've been asked to create a script which will read the contents of addresses.txt and output ONLY the MAC addresses listed in the text file. Could you give me some pointers or even a demo script with which to give me a boost? -- FR Hi FR, The last time someone asked the person...
  • Blog Post: How Can I Locate a Word in a Text File and Then Echo Back That Word and Any Remaining Text?

    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 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...
  • Blog Post: How Can I Combine Lines in a Text File?

    Hey, Scripting Guy! How can I combine lines in a text file? -- JN Hey, JN. So you need to know how to combine lines in a text file, huh? Well, to tell you the truth, we’re kind of in a hurry today; the Scripting Guy who writes this column is getting ready to head out to St. Peter’s and the Sistine...
  • Blog Post: How Can I Append a Blank Line to a Text File, Then Append the Current Date and Time?

    Hey, Scripting Guy! How can I append a blank line to a text file, then append the current date and time? -- PL Hey, PL. You know, back in the 1600s people were inordinately worried about witches and witchcraft. Fortunately, though, they developed a sure-fire test to determine whether or not someone...