[REBOL] How to change a file extension ?
From: pat665::ifrance::com at: 13-Jan-2002 17:52
How to change a file extension ?
Changing from %program.r to %program.bak
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
Divide and conquer:
1. How to find the file extension ?
2. How to replace on extension with another ?
short anwser : with find/last
The file extension is found like this.
print find/last myfile "." ; .r
infile: to-string %/d/rebol/prog.r/program.r
ext: find/last infile "."
outfile: copy/part infile (length? infile) - (length? ext)
append outfile ".bak"
It seems to me a bit complicated. Does anyone have a better (simpler)