[Macro error: Can't compile this script because of a syntax error.]

Part of the Samples Website. 10/12/96.

samples.["1996"].batchRenamer

«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)
continue
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")


You can download the current set of sample scripts from our FTP site. They're updated every night at 2AM or so. Dave