Example TOSHORT.PRT
; TOSHORT
;
; Program for Proteus
;
; (C) 2001-2004 Simone Zanella Productions
;
; This program renames to Dos format (8 + 3 characters) all files corresponding to filespec.

#!proteus -z

IF ISEMPTY(ARGV(5))
  CONSOLELN "Syntax:  TOSHORT filespec"
  CONSOLELN ""
  CONSOLELN "Purpose: renames to Dos format (8 + 3 characters) all files corresponding to filespec"
  ABORT 0
FI

Path = SplitPath(ARGV(5))
H = DIROPEN(ARGV(5), 1)
F = IIF(NEQ(H, -1), 1, 0)
A = AVLNEW()
WHILE GT(F, 0)
  AVLSET(A, DIRLAST(H, 1), ".")
  F = DIRNEXT(H)
LOOP
DIRCLOSE(H)
AVLTRAVERSE(A, RenameFile)
ABORT 0


FUNCTION FindExt(name)

P = STRRSTR(name, ".")
IF NEQ(P, 0)
  RETURN LEFT(UPPER(STRTRAN(RESTFROM(name, P), " ", "")), 4)
FI
RETURN ""


FUNCTION RenameFile(name, trash)

lfnsource = _Path name
ext = FindExt(name)
name = LEFT(STRTRAN(name, " ", ""), 8)
dossource = _Path name ext
pos = 1
WHILE ISFILE(dossource)
  IF LT(STRLEN(name), 8)
    name = name "1"
    pos = 1
  ELSE  
    Z = LEFT(RIGHT(name, pos), 1)
    IF LT(ASC(Z), ASC("Z"))
      N = INC(ASC(Z))
      IF LE(N, ASC("0"))
        N = ASC("1")
      ELSE
        IF AND(GT(N, ASC("9")), LT(N, ASC("A")))
          N = ASC("A")
        FI
      FI
      Z = CHR(N)
    ELSE          
      INC(@pos)
      CONTINUE
    FI
    name = LEFT(name, SUB(STRLEN(name), pos)) Z RIGHT(name, DEC(pos))
  FI
  dossource = _Path name ext
LOOP
CONSOLELN dossource
FRENAME(lfnsource, dossource)
RETURN 0


FUNCTION SplitPath(pathname)

P = STRRSTR(pathname, "\\")
IF NEQ(P, 0)
  RETURN LEFT(pathname, P)
FI
RETURN ""
Samples index Next example Previous example Contents Index
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell