Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: How to change a file extension ?

From: joel:neely:fedex at: 14-Jan-2002 9:50

Hi, Patrick, If you like shuffling cards, you'll love this solution: Patrick Philipot wrote:
> How to change a file extension ? > > Example: > Changing from %program.r to %program.bak > > Pitfall: > It cannot be done with a simple find and replace. Find and replace > will fail in some case like the following: > > /d/rebol/prog.r/program.r -> /d/rebol/prog.bak/program.r > /d/rebol/prog.r/program.r -> /d/rebol/prog.bak/program.bak >
change-tail: func [s [string!] t [string!] r [string!]] [ if (head reverse copy t) copy/part head reverse copy s length? t [ s: head reverse head change/part head reverse s head reverse copy r length? t ] s ]
>> change-tail "/d/rebol/prog.r/program.r" ".r" ".bak"
== "/d/rebol/prog.r/program.bak" Just for fun!!! -jn-