[REBOL] Combining bits that are the same
From: andrew::martin::colenso::school::nz at: 24-Jul-2003 9:59
Hi!
Have a look at these three scripts:
==========================
==========================
======================
=====
; Mass replace text content in files:
Mass_Replace: func [Folder [file!] Target [string!] Replacement
[string!]] [
map recursive-read Folder func [File [file!]] [
if %.dmt = extension? File [
probe File
write Folder/:File replace/all
read Folder/:File Target Replacement
]
]
]
Mass_Replace %"/N/CM/documents/2003 T3/" "SEPTEMBER 2002" "September
2003"
==========================
==========================
======================
=====
; Mass delete of files matching pattern:
foreach File recursive-read Folder: %"/C/Rebol/" [
if any [
%Thumbs.db = last Folder_File: split-path File
%.bak = extension? last Folder_File
] [
delete Folder/:File
probe Folder/:File
]
]
==========================
==========================
======================
=====
; Mass renaming of files matching pattern:
foreach File read Folder: %"/N/CM/documents/2003 T3/" [
if all [
%.dmt = extension? File
found? Index: find File Target: "T3 "
1 = index? Index
] [
probe File
attempt [rename Folder/:File copy find/tail File Target]
]
]
==========================
==========================
======================
=====
Notice how there are similarities? I'd like to express that similarity
in one function with a kind of "programmable" action. I get the feeling
that the Unix "GREP" command could be similar to what I want, but I've
got no familiarity with Unix or the GREP command. Anyone know if GREP
would a good model or goal to work towards with Rebol?
Thanks!
Andrew J Martin
Attendance Officer &
Information Systems Trouble Shooter
Colenso High School
Arnold Street, Napier.
Tel: 64-6-8310180 ext 826
Fax: 64-6-8336759
http://colenso.net/scripts/Wiki.r?AJM
http://www.colenso.school.nz/
DISCLAIMER: Colenso High School and its Board of Trustees is not responsible (or legally
liable) for materials distributed to or acquired from user e-mail accounts. You can report
any
misuse of an e-mail account to our ICT Manager and the complaint will be investigated.
(Misuse can come in many forms, but can be viewed as any material sent/received that
indicate or suggest pornography, unethical or illegal solicitation, racism, sexism, inappropriate
language and/or other issues described in our Acceptable Use Policy.)
All outgoing messages are certified virus-free by McAfee GroupShield Exchange 5.10.285.0
Phone: +64 6 843 5095 or Fax: +64 6 833 6759 or E-mail: [postmaster--colenso--school--nz]