Posts: 1,271
Threads: 399
Joined: Mar 2003
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.
Posts: 12,135
Threads: 142
Joined: Dec 2002
Maybe tokenize it using tok, get 3 chars from each word, and join.
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
Posts: 1,271
Threads: 399
Joined: Mar 2003
perfect !
thanks once again.
Posts: 1,271
Threads: 399
Joined: Mar 2003
i have to confess that i don't understand exactly how it works.
why is test.pdf returning no filename ?
Posts: 12,135
Threads: 142
Joined: Dec 2002
if(tok(name a)>1)
I changed the code, now works well.
Posts: 1,271
Threads: 399
Joined: Mar 2003
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 ...