sort by kind
sort by kind
Can XY sort files by kind e.g. group videos, audio, office, text files together?
Re: sort by kind
Sure. Write a custom column script...
One of my scripts helped you out? Please donate via Paypal
Re: sort by kind
may you please explain this?
Re: sort by kind
You need a script for a custom column that
- reads in all known generic file types - get("genericfiletype"...
- looks which gft the extension of the current item - <cc_item>
matches and return the gft name so you can sort with this column afterwards
Or you do the get("generic...
creation only one time, save it into a permanent variable and shorten the cc-script
to compare the extension with that list. Faster and more efficient because
the gfts change... very rarely^^
- reads in all known generic file types - get("genericfiletype"...
- looks which gft the extension of the current item - <cc_item>
matches and return the gft name so you can sort with this column afterwards
Or you do the get("generic...
creation only one time, save it into a permanent variable and shorten the cc-script
to compare the extension with that list. Faster and more efficient because
the gfts change... very rarely^^
One of my scripts helped you out? Please donate via Paypal
Re: sort by kind
Thanks for your interaction
this works fine as normal script
but as custom column doesn't work
also I do not know how I should use this:
I want custom column look like this
this works fine as normal script
Code: Select all
$Video = "mp4|mkv";
$Image = "jpg|png";
$ext = getpathcomponent(<curitem>, "ext");
if ("|$Video|" LikeI "*|$ext|*") {echo "Video"}
Code: Select all
$Video = "mp4,mkv";
$Image = "jpg,png";
$ext = getpathcomponent(<cc_name>, "ext");
if ("|$Video|" LikeI "*|$ext|*") {return video}
if ("|Image|" LikeI "*|$ext|*") {return Image}
Code: Select all
get("genericfiletype", "{:Video}", "|");
- Attachments
-
- 2017-04-10_232245.png (1 KiB) Viewed 1628 times
Re: sort by kind
Do you actually read your code?
LikeI checks for | and you use , as a separator
Image is not a variable here
Quote your strings^^
Code: Select all
$Video = "mp4,mkv";
$Image = "jpg,png";
$ext = getpathcomponent(<cc_name>, "ext");
if ("|$Video|" LikeI "*|$ext|*") {return "Video";}
if ("|Image|" LikeI "*|$ext|*") {return "Image";}
Image is not a variable here
Quote your strings^^
One of my scripts helped you out? Please donate via Paypal
Re: sort by kind
how to match folders?
Re: sort by kind
Code: Select all
exists()
One of my scripts helped you out? Please donate via Paypal
Re: sort by kind
Final script and no need to quote variables.. thanks for your help
Code: Select all
$ext = "<cc_ext>";
$Video = get("genericfiletype", "{:Video}", "|");
$Audio = get("genericfiletype", "{:Audio}", "|");
$Image = get("genericfiletype", "{:Image}", "|");
$Subtitle = "srt|ass|ssa|sub|smi|sup|lrc";
$Text = get("genericfiletype", "{:Text}", "|");
$Archive = get("genericfiletype", "{:Archive}", "|");
$Office = get("genericfiletype", "{:Office}", "|");
$Executable = get("genericfiletype", "{:Executable}", "|");
$Web = get("genericfiletype", "{:Web}", "|");
$Font = get("genericfiletype", "{:Font}", "|");
if (<cc_isfolder> == 1) { return Folder }
if ("|$Video|" LikeI "*|*.$ext|*") { return video }
if ("|$Audio|" LikeI "*|*.$ext|*") { return Audio }
if ("|$Image|" LikeI "*|*.$ext|*") { return Image }
if ("|$Subtitle|" LikeI "*|$ext|*") { return Subtitle }
if ("|$Text|" LikeI "*|*.$ext|*") { return Text }
if ("|$Archive|" LikeI "*|*.$ext|*") { return Archive }
if ("|$Office|" LikeI "*|*.$ext|*") { return Office }
if ("|$Executable|" LikeI "*|*.$ext|*") { return Executable }
if ("|$Web|" LikeI "*|*.$ext|*") { return Web }
if ("|$Font|" LikeI "*|*.$ext|*") { return Font }
if ($ext != "") { return Other }
if ($ext = "*.") { return Unknown }
Re: sort by kind
I didn't say quote your variables, I said "quote your strings" (which you aren't...)and no need to quote variables
And btw, why do you quote variables?
Code: Select all
$ext = "<cc_ext>";
While what you're doing here works, it is very inefficient.
1. Each single item in your list get's all genericfiletypes that you've defined here
Let's say you've generated a list like that (just for demonstration):
Code: Select all
Archive|7z,bz,bz2,cab,gz,Img,iso,lha,lzh,rar,tar,taz,tbz,tbz2,tgz,tz,wmz,wsz,yfs,z,zip,zipx
Audio|wav,mp3,mid,cda,au,ogg,ape,m4a,mpc,mp+,mpp,wma,asf,flac,aif,aiff,aifc,au,wv,wva
Executable|bat,cmd,com,exe,scr
Font|fon,ttf,otf,pfb,pfm
Image|gif,ico,cur,emf,wmf,png,bmp,dib,rle,tga,tpic,dds,hdr,pic,pict,jpg,jpeg,jpe,psb,psd,arw,cpt,cr2,crw,dcr,dng,erf,fff,mrw,mef,nef,nrw,orf,pef,raf,raw,rw2,rwl,sr2,srf,srw,x3f,tif,tiff
Office|cdr,csv,rtf,doc,dot,docm,docx,dotx,xls,xlt,xlsm,xlsx,xltx,ppt,pot,pps,pptx,potx,ppsx,odt,ods,odp,wpd,wpf,one,pdf,eps,jtx,xps,oxps,dwg,dwf,dwfx,dxf,easmx,edrwx,eprtx,sldprt,sldasm,slddrw,eml,msg,nws,zip
Photo|jpg,jpeg,jpe,tif,tiff,arw,cpt,cr2,crw,dcr,dng,erf,fff,mrw,mef,nef,nrw,orf,pef,raf,raw,rw2,rwl,sr2,srf,srw,x3f,tif,tiff,psb,psd
Text|adml,admx,ahk,asc,asp,aspx,au3,b64,bas,bat,c,htaccess,cer,cfg,cmd,cls,conf,config,cnt,ctl,cpp,crt,cs,css,cws,cue,dat,eml,filters,frm,h,hpp,htc,htm,html,ics,idl,inc,inf,ini,java,js,json,less,lng,log,lrc,lst,lua,m3u,m3u8,manifest,man,map,markdown,md,mht,mhtm,mhtml,mim,mk,msg,nfo,nsi,nws,odl,opml,php,pl,prj,py,pyw,rc,rdf,reg,resx,rst,scss,sh,sql,srt,tbl,txt,uue,url,utf8,vb,vbp,vbs,vbw,vcf,website,wpl,ws,xml,xsd,xsl,xslt,xxe,xys
Vector|ai,cdr,cgm,dwg,dwf,dwfx,dxf,emf,eps,epsf,pdf,ps,svf,svg,svgz,wmf,jtx,xps,oxps
Video|3gp,asf,avi,blend,divx,flv,mov,qt,mkv,mpg,mpeg,mpa,mpe,m1v,m2v,mp2,mp4,m4r,m4v,mpv,mpv2,mts,m2ts,ogm,ra,ram,rm,rmvb,vob,ts,webm,wmv
Web|htm,html,shtml,mht,mhtm,mhtml,php,php3,php4,php5,htaccess,cfg,inc,asp,aspx,xml,swf,svg,svgz,url,zip
And then the code for a cc can be shortened like that (missing your folder, other and unknown checks):
Code: Select all
perm $genericFileTypes;
$match = gettoken(regexmatches($genericFileTypes, "(^.*(\||,)<cc_ext>(,|$))", <crlf>), 1, <crlf>);
return gettoken($match, 1, "|");
One of my scripts helped you out? Please donate via Paypal
Re: sort by kind
clean and clever very thanks.