Saving Time
I recently found myself needed to rename a bunch of files in a fairly repetitive way. Many files, similar changes, but different enough to require visual inspection.
After doing the first set manually, I thought it would be easy to write a script to handle it, but that seemed like overkill. My next thought was to use BBEdit and regular expressions to manipulate the files.
BBEdit has two features that made this much easier than I expected.
- Apply Text Transform
- Found in the Text menu "Apply Text Transform..." is a feature that lets you manipulate text in one or more files in a programatic way. In my case I added line numbers to the front of a list of file names.
- Pattern Playground
- Found in the Search menu "Pattern Playground" is a great tool for testing regular expressions against your current text. Once you have perfected your expressions you can use them in to find and replace text in your document.
I used these tools to prepend line numbers, then change the text to a list of unix move commands with the line number replacing part of the destination file name.
There are so many features in BBEdit that I haven't used, but I continue to find it to be better than fancier code editors that I have paid more money to use.