Category: Scripting
Removing certain text in multiple filenames in OS X
I had a large number of ebooks that looked like the following: Walter%20Isaacson%20-%20Einstein_His%20Life%20And%20Universe.mobi And because I’m lazy, I looked for an automated way to clean all of them up. This is how: 1. Back up all your files in another directory2. Launch terminal3. Go to the directory you’d like to perform the changes4. Type: for…
Excel: Insert multiple rows every other row
The key is to use a macro. To do so, hit Alt+F11, then create a new macro and add the code below. Once added, select the worksheet you’d like to process, change the “17” below (1 if to process all rows), then run it. That’s it. Sub Insert_Blank_Rows() Dim Last As Integer, oRow As…
PowerShell: Deleting entire lines in a text file based on a partial string match
PS C:\workspace> (gc “fileToParse.txt”) -notmatch "<criteria>" | out-file "resultFile.txt" Note: <Criteria>, for example, “not".
PowerShell: Rename file to lowercase
1. Open PowerShell 2. CD into directory to work on 3. Execute the following command: get-childitem * -recurse | rename-item -newname { $_.name.ToLower() }
PowerShell: Rename file’s file extension
1. Open PowerShell 2. CD into directory to work on 3. Execute the following command: get-childitem * -recurse | rename-item -newname { $_.name -replace ".txt",".bcp" }
Read a file with bash
I had to test our download servers at work right away, i.e., HTTP vs HTTPS, which required downloading a large number of files. A file list was given to me to work with, like so: /download/integrations/file1.exe/download/us/update/patch/file1.exe/download/us/cab/file1.exe So I decided to use the bash shell to read each line and run wget quick and dirty. Here’s the…