Part of the Samples Website. 8/16/97.


«From a request on the Mac Scripting list...
«I'm looking for something that would allow me rename files based on a pattern
«matching scheme. For example, I want to rename the files
«H001-001.tngif, H001-002.tngif, H001-003.tngif,...
«to H001001.gif, H001002.gif, H001003.gif,...
«Add a call to this script to the Finder's menu bar, at system.menubars.MACS.
«In the Finder, select the folder you want to operate on.
«And choose the command from the Finder's menu bar.
local (folder)
for folder in FinderMenu.getSelectionList ()
if not file.isFolder (folder)
local (f, fname, suffix)
fileloop (f in folder, infinity)
fname = file.fileFromPath (f)
suffix = string.nthField (fname, '.', 2)
if suffix == "tngif"
local (namepart = string.nthField (fname, '.', 1))
namepart = string.replaceAll (namepart, "-", "1")
file.rename (f, namepart + ".gif")

This page was last built on Sat, Aug 16, 1997 at 6:43:21 PM. You can download the current set of sample scripts from our FTP site. Dave