-- file : replace.ex -- author : jiri babor & easy modify RittyNT -- email : jbabor@paradise.net.nz, baramount@gmail.com -- project : search & replace -- tool : euphoria 2.1 & 3.1.1 -- date : 99-11-27, MMX -- version : 1.10 to 1.10b -- modify : file list (*.???) and subdirectory ---------------------------------------------------------------------- -- Usage:[ex] replace old_text new_text file1 file2 file3 -- or -- Usage:[ex] replace @[Script file] files(s) -- (*.???) -- or -- Usage:[ex] replace <@[Script file] [!]files(s) all subdirectory ---------------------------------------------------------------------- -- Replace [case sensitive] all occurances of old_text string with new_text string -- -- in all specified files. -- -- Strings containing spaces must be enclosed in quotation marks! -- ---------------------------------------------------------------------- -- ************** Play safe! Back up your files! ************** -- ---------------------------------------------------------------------- include file.e include get.e sequence buffer, cl, filename, files, new_text, old_text,tmp, line,fn,data,xpath,dirs,file integer f1,f0,view,flag object xx function ListDirs(sequence startpath) sequence y object x integer z, SLASH SLASH = '\\' if startpath[length(startpath)] != SLASH then startpath = startpath & SLASH end if x = {} y = {startpath} z = 1 while z <= length(y) do x = dir(y[z]) if not atom(x) then for i = 1 to length(x) do if find('d',x[i][D_ATTRIBUTES]) then if compare(x[i][D_NAME], ".") != 0 then if compare(x[i][D_NAME],"..") != 0 then y = y & {y[z] & x[i][D_NAME] & SLASH} end if end if end if end for end if z = z + 1 end while return y[2..length(y)] -- fixed by Travis May, Dec. 29, 2001 end function function DIR(object wrk) object w0 sequence w1 w0 = dir(wrk) if atom(w0) then w1 = "" else w1 = w0 end if return w1 end function function TRIM(sequence wrk) integer j for i = length(wrk) to 1 by -1 do j = i if wrk[i] > 32 then exit end if end for if (j > 0) then return wrk[1..j] else return wrk end if end function procedure help(sequence message) clear_screen() puts(1,"REPLACE Ver:1.10b") puts(1," (c)Jiri Babor & RittyNT \n") puts(1,"\n") puts(1,"Easy modify Find & [case sensitive]Replace program \n") puts(1,"\n") puts(1,"[ex] REPLACE old_text new_text [file1] [file2].. \n") puts(1," or \n") puts(1,"[ex] REPLACE old_text new_text <*.???> \n") puts(1," or \n") puts(1,"[ex] REPLACE old_text new_text <[!]*.???> all subdir \n") puts(1," or \n") puts(1,"[ex] REPLACE @