Home
About
Agents
CGIs
Mac
Macros
Misc
Stories
Suites
Websites
Outline
Frontier
Scripting

File Based Search/Replace

When you want to do a search-replace for all text files in a folder, first select the folder in the Mac Finder, then run this script.

It prompts you for a search string and a replace string.

All text files in the folder are searched. Any file that contains the search string is processed and then rewritten.

The names of all the files that contain the search string appear in the Main Window.

This script is Mac-specific. When we nail down the cross-platform way of working with file paths it should be updated.

Why I wrote it

I needed to fix a bunch of non-relative URLs in a large website.

Pointers

You can link this script into the Finder's menu bar by editing system.menubars.MACS.

See Your First Script for a tutorial on doing that.

For more utilities that run from the Mac Finder's menu bar, see The Finder and Frontier.

If you don't have Frontier, here's a listing of the source code for the file search replace script.


This is a fat web page containing workspace.fileSearchReplace. More info on fat pages here.

© copyright 1997-98 UserLand Software. This page was originally posted on 9/14/97; 9:38:56 AM and it was last built on 9/11/98; 9:23:02 AM. Webmaster: dave@userland.com.