$INCLUDE "rapidq.inc"
trimfront=0
trimrear=0
croplen=8
dragdist=0
croptoggle=-1
enumeratetoggle=-1
enumeratebase=0
enumeratelen=1
renametoggle=-1
DECLARE SUB changedirectory
DECLARE SUB renameroutine
DECLARE SUB togglecrop
DECLARE SUB toggleenumerate
DECLARE SUB togglerename
DECLARE SUB checkbounds
CREATE form AS QFORM
height=480
width=450
center
borderstyle=bsdialog
CREATE dirlist AS QFILELISTBOX
showicons=1
addfiletypes(ftdirectory)
delfiletypes(ftnormal)
onclick=changedirectory
height=340
width=225
END CREATE
CREATE filebox AS QFILELISTBOX
showicons=1
multiselect=1
addfiletypes(fthidden, ftsystem, ftarchive, ftreadonly)
onclick=changedirectory
ondblclick=renameroutine
left=225
height=340
width=225
END CREATE
CREATE removestring AS QEDIT
top=347
left=50
width=100
height=26
END CREATE
CREATE addstring AS QEDIT
top=347
left=200
width=100
height=20
END CREATE
CREATE button AS QBUTTON
CAPTION="rename!"
top=347
left=340
height=22
onclick=renameroutine
END CREATE
CREATE removetext AS QLABEL
CAPTION="remove"
top=350
left=5
END CREATE
CREATE addtext AS QLABEL
CAPTION="add"
top=350
left=170
END CREATE
CREATE trim1txt AS QLABEL
CAPTION="trim"
top=380
left=5
END CREATE
CREATE trimfrontbox AS QEDIT
text=STR$(trimfront)
top=377
left=30
height=26
width=30
onchange=checkbounds
END CREATE
CREATE trim3txt AS QLABEL
CAPTION="from front"
top=380
left=70
END CREATE
CREATE trimrearbox AS QEDIT
text=STR$(trimrear)
top=377
left=130
height=26
width=30
onchange=checkbounds
END CREATE
CREATE trim5txt AS QLABEL
CAPTION="from rear"
top=380
left=170
END CREATE
CREATE croptext1 AS QLABEL
CAPTION="crop to"
top=380
left=300
END CREATE
CREATE croplenbox AS QEDIT
text=STR$(croplen)
top=377
left=345
height=26
width=30
onchange=checkbounds
END CREATE
CREATE croptext2 AS QLABEL
CAPTION="chars"
top=380
left=385
END CREATE
CREATE croptogglelabel AS QCHECKBOX
top=379
left=425
onclick=togglecrop
END CREATE
CREATE enumerlabel1 AS QLABEL
CAPTION="number from"
top=410
left=210
END CREATE
CREATE enumeratebasebox AS QEDIT
text=STR$(enumeratebase)
top=407
left=275
height=26
width=30
onchange=checkbounds
END CREATE
CREATE enumerlabel2 AS QLABEL
CAPTION="# of digits"
top=410
left=320
END CREATE
CREATE enumeratelenbox AS QEDIT
text=STR$(enumeratelen)
top=407
left=375
height=26
width=30
onchange=checkbounds
END CREATE
CREATE enumeratetogglelabel AS QCHECKBOX
top=409
left=425
onclick=toggleenumerate
END CREATE
CREATE replacelabel AS QLABEL
CAPTION="replace"
top=410
left=5
END CREATE
CREATE renametogglelabel AS QCHECKBOX
top=409
left=50
width=20
onclick=togglerename
END CREATE
CREATE insert1label AS QLABEL
CAPTION="insert"
top=410
left=75
END CREATE
CREATE insert1togglelabel AS QCHECKBOX
top=409
left=110
width=20
END CREATE
CREATE insert2label AS QLABEL
CAPTION="at end"
top=410
left=130
END CREATE
CREATE insert2togglelabel AS QCHECKBOX
top=409
left=170
width=20
END CREATE
CREATE warning AS QLABEL
CAPTION="***WARNING: ALWAYS SELECT MULTIPLE FILES FROM BOTTOM TO TOP***"
top=440
left=28
END CREATE
CAPTION=dirlist.directory
SHOWMODAL
END CREATE
SUB changedirectory
CHDIR(dirlist.item(dirlist.itemindex) - "[" - "]")
dirlist.directory=CURDIR$
filebox.directory=CURDIR$
form.CAPTION=CURDIR$
END SUB
SUB renameroutine
DIM suflen AS INTEGER
DIM t AS INTEGER
DIM processcount AS INTEGER
DIM processindex AS INTEGER
DIM newfilename$ AS STRING
DIM literalname$ AS STRING
DIM suffix$ AS STRING
DIM makeanumb$ AS STRING
DIM proccount AS INTEGER
proccount=0
processcount=0
processindex=0
processcount=filebox.selcount
processindex=filebox.itemindex
IF processcount=1 THEN
newfilename$=REPLACESUBSTR$(filebox.filename,removestring.text,addstring.text)
suflen=1+LEN(newfilename$)-rinstr(newfilename$,".")
suffix$=RIGHT$(newfilename$,suflen)
literalname$=LEFT$(newfilename$,LEN(newfilename$)-suflen)
IF LEN(literalname$)>trimfront THEN literalname$=RIGHT$(literalname$,LEN(literalname$)-trimfront)
IF LEN(literalname$)>trimrear THEN literalname$=LEFT$(literalname$,LEN(literalname$)-trimrear)
IF croptoggle>0 AND LEN(literalname$)>croplen THEN literalname$=LEFT$(literalname$, croplen)
IF renametoggle>0 AND addstring.text<>"" THEN literalname$=addstring.text
IF renametoggle>0 AND addstring.text="" AND enumeratetoggle>0 THEN literalname$=addstring.text
makeanumb$=STR$(enumeratebase)
FOR buildcount=LEN(makeanumb$)+1 TO enumeratelen
makeanumb$="0"+makeanumb$
NEXT buildcount
IF enumeratetoggle>0 THEN literalname$=literalname$+makeanumb$
newfilename$=literalname$+suffix$
RENAME (DIR$(filebox.filename,faanyfile), newfilename$)
ELSE
FOR t=(processindex) TO (processcount+processindex-1)
newfilename$=REPLACESUBSTR$(filebox.item(t),removestring.text,addstring.text)
suflen=1+LEN(newfilename$)-rinstr(newfilename$,".")
suffix$=RIGHT$(newfilename$,suflen)
literalname$=LEFT$(newfilename$,LEN(newfilename$)-suflen)
IF LEN(literalname$)>trimfront THEN literalname$=RIGHT$(literalname$,LEN(literalname$)-trimfront)
IF LEN(literalname$)>trimrear THEN literalname$=LEFT$(literalname$,LEN(literalname$)-trimrear)
IF croptoggle>0 AND LEN(literalname$)>croplen THEN literalname$=LEFT$(literalname$, croplen)
IF renametoggle>0 AND addstring.text<>"" THEN literalname$=addstring.text
IF renametoggle>0 AND addstring.text="" AND enumeratetoggle>0 THEN literalname$=addstring.text
IF insert1togglelabel.checked>0 THEN literalname$=addstring.text+literalname$
IF insert2togglelabel.checked>0 THEN literalname$=literalname$+addstring.text
makeanumb$=STR$(enumeratebase+proccount)
proccount=proccount+1
FOR buildcount=LEN(makeanumb$)+1 TO enumeratelen
makeanumb$="0"+makeanumb$
NEXT buildcount
IF enumeratetoggle>0 THEN literalname$=literalname$+makeanumb$
newfilename$=literalname$+suffix$
RENAME (DIR$(filebox.item(t),faanyfile), newfilename$)
NEXT t
END IF
filebox.update
END SUB
SUB togglecrop
croptoggle=croptoggle*-1
IF renametoggle=1 THEN croptogglelabel.checked=false
IF renametoggle=1 THEN croptoggle=-1
END SUB
SUB toggleenumerate
enumeratetoggle=enumeratetoggle*-1
END SUB
SUB togglerename
renametoggle=renametoggle*-1
croptoggle=-1
croptogglelabel.checked=false
END SUB
SUB checkbounds
trimfront=VAL(trimfrontbox.text)
trimrear=VAL(trimrearbox.text)
croplen=VAL(croplenbox.text)
enumeratebase=VAL(enumeratebasebox.text)
enumeratelen=VAL(enumeratelenbox.text)
IF trimfront<0 THEN trimfront=0
IF trimrear<0 THEN trimrear=0
IF croplen<1 THEN croplen=1
IF enumeratebase<0 THEN enumeratebase=0
IF enumeratelen<1 THEN enumeratelen=1
IF trimfront>99 THEN trimfront=0
IF trimrear>99 THEN trimrear=0
IF croplen>99 THEN croplen=1
IF enumeratebase>9999998 THEN enumeratebase=9999998
IF enumeratelen>9 THEN enumeratelen=9
trimfrontbox.text=STR$(trimfront)
trimrearbox.text=STR$(trimrear)
croplenbox.text=STR$(croplen)
enumeratebasebox.text=STR$(enumeratebase)
enumeratelenbox.text=STR$(enumeratelen)
END SUB
|