
-----------------------------------
Zren
Sun Mar 08, 2009 12:39 pm

Mass File Extension Converter
-----------------------------------
Should you ever come accross a heptillion of files with the wrong file extension.
Contains a hacky slashy version of Java's split(). For some reason I couldn't get it too work as a flexible when used as a flexible array.

View.Set ("graphics:480;max,nobuttonbar,title:Mass File Extension Converter")
colourback (black)
colour (brightgreen)
cls

var streamNumber : int
var fileName : string
streamNumber := Dir.Open (Dir.Current)
assert streamNumber > 0
var fileProbe := false

var file : flexible array 1 .. 0 of string

var t : flexible array 1 .. 0 of string

procedure split (p : string)
    var l := 1
    for i : 1 .. length (p)
        if p (i) = "." then
            new t, upper (t) + 1
            t (upper (t)) := p (l .. i - 1)
            l := i + 1
        elsif i = length (p) then
            new t, upper (t) + 1
            t (upper (t)) := p (l .. i)
        end if
    end for
end split

function fileExt (s : string) : string
    split (s)
    result t (upper (t))
end fileExt

function fileStruct (s : string) : string
    var w : string := ""
    split (s)
    for i : 1 .. upper (t) - 1
        w += t (i)
        if i < upper (t) - 1 then
            w += "."
        end if
    end for
    result w
end fileStruct

process getFiles
    loop
        fileName := Dir.Get (streamNumber)
        exit when fileName = ""
        new file, upper (file) + 1
        file (upper (file)) := fileName
    end loop
    fileProbe := true
end getFiles


var EXT1 : string := ""
var EXT2 : string := ""

put "Mass File Extension Changer"
put "Current Extension (No .) 

-----------------------------------
Tallguy
Wed Mar 11, 2009 7:57 am

RE:Mass File Extension Converter
-----------------------------------
interesting concept, i like how you did it, how long did it take?

-----------------------------------
blankout
Mon Apr 27, 2009 7:03 pm

Re: Mass File Extension Converter
-----------------------------------
good, the only problem i found is that it doesn't say how long it took to convert the files, i only ever get a 0. Maybe its just me but thought I'd point it out anyway

-----------------------------------
bbi5291
Mon Apr 27, 2009 8:21 pm

Re: Mass File Extension Converter
-----------------------------------
Another shameless post in an effort to raise my post count
Should you ever come accross a heptillion of files with the wrong file extension.
It's "septillion", not "heptillion" (short scale 10^24, long scale 10^42)

-----------------------------------
tjmoore1993
Tue Apr 28, 2009 7:08 pm

RE:Mass File Extension Converter
-----------------------------------
I like the idea but there isn't much use for it because converting process only works with files written in ASCII format basically. Correct me if I am wrong. Anyways I tried it and just so I can say I used it. 


I converted some project files to a new extension. Thanks! :)
