«http://www.scripting.com/fatPages/09/fileSearchReplace.html |
| «Sun, Sep 14, 1997 at 9:40:56 AM by DW |
local (filelist = FinderMenu.getSelectionList ()) |
| scripterror ("Please select a folder in the Finder.") |
if sizeof (filelist) != 1 |
local (folder = filelist [1]) |
if not file.isfolder (folder) |
local (foldername = file.fileFromPath (folder) - ":") |
if not dialog.ask ("Search '" + foldername + "' for what string?", @scratchpad.searchfor) |
if not dialog.ask ("Replace with what string?", @scratchpad.replacewith) |
local (filetext, filetype) |
fileloop (f in folder, infinity) |
| filetext = toys.readWholeFile (f) |
| if filetext contains scratchpad.searchfor |
| filetext = string.replaceAll (filetext, scratchpad.searchfor, scratchpad.replacewith) |
| toys.writeWholeFile (f, filetext, filetype, file.creator (f), file.created (f)) |