home *** CD-ROM | disk | FTP | other *** search
- v$="$VER: Sufferer 1.2 (16.1.99) James L Boyd"
-
- ; add/change multiple file suffixes...
-
- ; Author : James L Boyd - jamesboyd@all-hail.freeserve.co.uk
-
- Function.w CentreWindowX {width.w}
- x.w=(ScreenWidth/2)-(width/2)
- Function Return x
- End Function
-
- Function.w CentreWindowY {height.w}
- y.w=(ScreenHeight/2)-(height/2)
- Function Return y
- End Function
-
- Function.w TitleBarHeight{scr.b}
-
- If Peek.l(Addr Screen(scr))
- *scr.Screen=Peek.l(Addr Screen(scr)) ; get screen info...
- Function Return *scr\BarHeight+1
- Else Function Return False
- EndIf
-
- End Function
-
- NoCli
- WBStartup ; run from an icon
- FindScreen 0 ; find front screen and use it (for requesters)
-
- ; this function returns the file part of "path:drawer/file" :
- Function$ StripFile{a$}
- *fileptr.l = FilePart_(&a$)
- a$=Peek$(*fileptr)
- Function Return a$
- End Function
-
- ; this looks backwards through the filename for a dot...
-
- Function$ StripToDot{a$}
- For a.w=Len(a$) To 1 Step -1
- If Mid$(a$,a,1)="." Then a$=Left$(a$,a-1):Pop For:Goto senditback
- ; if it found a dot,puts result into b$,goes to senditback label below
- Next a
- senditback
- Function Return a$
- End Function
-
- #maxfiles=5000
-
- Dim fil$(#maxfiles) ; max no of files
- path$="RAM:" ; default drawer
- pat$="#?" ; file pattern
-
- .select_files
-
- counter.w=0 ; keep track of files!
-
- RTEZSetDefaultDirectory 2,path$
- RTEZSetDefaultDirectory 3,path$
- RTEZSetPattern 3,pat$
-
- ret.b=RTEZMultiLoadFile("Select file(s) to Suffer!")
-
- If ret ; files chosen
-
- fil$(counter)=RTNextPathEntry ; can't remember why you have to
- ; do a dummy one...
-
- ; now read 'em :
-
- While fil$(counter)<>"" AND ret
- counter+1
- If counter>#maxfiles
- rt.b=RTEZRequest("Sufferer","Oops - maximum of #maxfiles files!","Doh!")
- Pop If:Pop While:Goto select_files
- EndIf
- fil$(counter)=RTNextPathEntry
- Wend
-
- info$="Enter new suffix or type STRIP to strip suffixes"
-
- suffer$=RTEZGetString("Sufferer",info$,10)
-
- ; WARNING ! This command is bugged,and causes an Enforcer
- ; hit if Cancel if clicked on,or an empty string
- ; given (hence the Abort default string) !
-
- If suffer$="" Then End
- If UCase$(suffer$)="STRIP" Then suffer$=""
-
- If Len(suffer$)>0 Then If Left$(suffer$,1)<>"." Then suffer$="."+suffer$
-
- error.b=0:error$="Error renaming the following files :||"
-
- ; Now SUFFER,YOU BASTARDS!!!! RRRRRGGHHHHHH!!!!!!
-
- Window 0,CentreWindowX{ScreenWidth/4},CentreWindowY{TitleBarHeight{0}},ScreenWidth/4,TitleBarHeight{0},0,"Sufferer",1,2
-
- suc.l=PICreateRequest("Suffering...",0,counter-1)
-
- For a.w=0 To counter-1
-
- icon.b=0
-
- ; make it suffer - ahem,add the suffix :
-
- If Right$(fil$(a),5)=".info"
- b$=StripToDot{Left$(fil$(a),Len(fil$(a))-5)}
- b$+suffer$+".info"
-
- Else
- b$=StripToDot{fil$(a)}+suffer$
- EndIf
-
- If Rename_ (&fil$(a),&b$)=0 Then error$+fil$(a)+"|":error=1
-
- If suc Then WaitTOF_:dummy.l=PIUpdateRequest (a)
-
- Next a
-
- If suc Then PIEndRequest
-
- If error Then rt.b=RTEZRequest("Sufferer",error$,"Check protect tags...")
-
- EndIf ; from "If ret" ...
-
- Free Window 0
-
- quit
- End
-