[OFF] utility for files

Yennie at aol.com Yennie at aol.com
Sat Feb 15 20:27:13 CST 2003


Since someone mentioned Metacard for this...

This script works nicely for me- it supports matching files with a filter 
function (note: this is not regex, just expansion such as "*.cpp"), nested 
folders, and deleting originals. Known limitation: resource forks are not 
copied.

I posted a copy of the stack which runs it here:
http://members.aol.com/yennie/rename.mc

Of course test on a copy of your files if you intend to use it: I've tested 
it several times here and I can't see any problem with it, but I make no 
warranties and it DOES delete files.

Here's the script in case anyone is interested, or wants to put it in a 
command line script:

on renameFiles theDirectory, thePrefix, theFilter, wantsRecurse, wantsDelete
   put the directory into saveDirectory
   set the directory to theDirectory

   put the files into fileList
   filter fileList with theFilter
   repeat for each line theFile in fileList
     if (char 1 of theFile = ".") then next repeat
     put url ("binfile:"&theDirectory&theFile) into url ("binfile:"&
theDirectory&thePrefix&theFile)
     if (wantsDelete) then delete file (theDirectory&theFile)
   end repeat

   if (wantsRecurse) then
     repeat for each line theFolder in the folders
       if (char 1 of theFolder = ".") then next repeat
       renameFiles (theDirectory&theFolder&"/"), thePrefix, theFilter, 
wantsRecurse, wantsDelete
     end repeat
   end if

   set the directory to saveDirectory
end renameFiles


More information about the Valentina mailing list