«Adds a copyright notice at the top of each text file in a folder
«We needed this script for a folder full of C source code
«The script is smart -- it replaces a pre-existing copyright notice
local (folder, prefix, text, f, createddate, moddate, origcreator)
if not file.getFolderDialog ("Choose a folder of text files", @folder)
return
prefix = "\r/*© copyright 1993 Mancuso Investigations, Inc. All RIghts Reserved.*/\r\r\r"
on deletewhitespace (text)
local (ch)
loop
if sizeOf (text) == 0
return ("")
ch = text [1]
if (ch [not equal] 'r') and (ch [not equal] ' ') and (ch [not equal] tab)
return (text)
text = string.delete (text, 1, 1)
fileloop (f in folder, infinity)
if file.type (f) == 'TEXT'
msg (file.fileFromPath (f))
createddate = file.created (f)
origcreator = file.creator (f)
moddate = file.modified (f)
file.open (f)
text = string (file.read (f, infinity))
file.close (f)
text = deletewhitespace (text)
if text beginsWith "/*©"
text = string.delete (text, 1, string.patternMatch ("\r", text))
text = deletewhitespace (text)
text = prefix + text
file.new (f)
file.setType (f, 'TEXT')
file.setCreator (f, origcreator)
file.open (f)
file.write (f, text)
file.close (f)
file.setCreated (f, createddate) «same creation date as original
file.setModified (f, moddate) «same modification date as original
This page was last built on Sat, Aug 16, 1997 at 6:31:41 PM. You can download the current set of sample scripts from our FTP site. Dave |