Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random filenames or shorten it
#1
can you give me an example on how to create a random filename and shorten it
from a file ?

like 'super documentation about super scripting.pdf'
to
'scrdocsup.pdf'

thanks.
pi
#2
Maybe tokenize it using tok, get 3 chars from each word, and join.

Code:
Copy      Help
str s="super documentation about super scripting.pdf"
str name.getfilename(s) ext=s+name.len
ARRAY(str) a; int i; str ss
if(tok(name a)>1)
,for(i 0 a.len)
,,str& r=a[i]
,,if(r.len>3) r.fix(3); r.rtrim("aeiyou"); r[0]=toupper(r[0])
,,ss+r
,ss+ext
else ss=s
out ss
#3
perfect !
thanks once again.
pi
#4
i have to confess that i don't understand exactly how it works.
why is test.pdf returning no filename ?
pi
#5
if(tok(name a)>1)

I changed the code, now works well.
#6
Code:
Copy      Help
str s="super5.pdf"
str name.getfilename(s) ext=s+name.len
ARRAY(str) a; int i; str ss
if(tok(name a)>1)
,for(i 0 a.len)
,,str& r=a[i]
,,if(r.len>3) r.fix(3); r.rtrim("aeiyou"); r[0]=toupper(r[0])
,,ss+r
,ss+ext
else ss=s
out ss

returns super5.pdf

no scamble ...
pi


Forum Jump:


Users browsing this thread: 2 Guest(s)