Scripting Blog [archived]

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

Hey, Scripting Guy! How Can I Move Files Based on a Portion of the File Name?

(image) Hey, Scripting Guy! I have tens of thousands of files that all have a file name that includes a number bounded by two underscore characters; for example, P_19_L00.jpg. I need to figure out which number is embedded in a file name, then move that file to a folder named after that number. In this case, that means moving P_19_L00.jpg to ...

Hey, Scripting Guy! How Can I Replace Incorrect Dates in My File Names?

(image) Hey, Scripting Guy! have a folder that has a whole bunch of files in it. Many of those files have a file name that includes an incorrect date; for example, the file might be named FGA Site Visit 2-14-07 204.jpg when it should really be named FGA Site Visit 2-14-08 204.jpg. (That is, it suggests the visit occurred in 2007 rather than ...

Hey, Scripting Guy! How Can I Extract Three-Digit Numbers From a String?

(image) Hey, Scripting Guy! I’m trying to use regular expressions to extract three-digit numbers that are enclosed by pipe characters; they embedded in string values like this: |159|468|572|843|. However, I can’t figure out the syntax that will get this to work. Can you help me?-- RS (image) (image) (image) Hey, RS. Before we ...

How Can I Locate Strings That Consist of a Series of Numbers Followed by .ZIP?

(image) Hey, Scripting Guy! I have a file which includes a number of file names. All of these names consist of a series of numbers followed by a .zip file extension; for example, 1234.zip, 5678.zip, etc. How can I write a script that locates all these file names and then saves just the names to a second file?-- RS(image) (image) (image) ...

How Can I Verify That All the Characters in a String are Either A-to-Z (Uppercase Letters) or the Digits 0-through-9 in a HTA?

(image) Hey, Scripting Guy! In an HTA, how can I verify that all the characters are either A-to-Z (uppercase letters) or the digits 0-through-9?-- MB(image) (image) (image) Hey, MB. You want to talk irony? Oh. Well, we’re going to talk irony anyway. In yesterday’s column we tried to be cute, posing as the illegitimate children of a non...