Icon Help

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
strettonbull
Posts: 2
Joined: 23 Mar 2017 10:53

Icon Help

Post by strettonbull »

Hi,

New to this forum, so hello to everyone.

I need help with a script to show a different icon depending on whether the file type is a flac, an mp3, or a jpg file.

So far I have come up with the following, but it returns the flac icon for every file.

Code: Select all

$base = getpathcomponent(<cc_name>, "base");
if (type($base) = flac) {
  return "flac.ico";
} elseif (type {$base} = mp3) {
  return "mp3.ico";
} else {
  return "jpg.ico";
}
Ideally I would like it to work based on the file extension, rather than the file type.

I'm new to scripting, so I'm sorry if this is something obvious.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Icon Help

Post by bdeshi »

hey, welcome to the forum!

There are a few problems with your script:
1. $base = getpathcomponent(<cc_name>, "base"); - You want the EXTension, not the base name
2. type($base) - type() - where did you get this?
3. Your code will give the jpg icon to all items that do not match at all.
Now, use this script instead:

Code: Select all

 $ext = <cc_ext>;
 if ($ext == "flac") {
   return "flac.ico";
 } elseif ($ext == "mp3") {
   return "mp3.ico";
 } elseif ($ext == "jpg") {
   return "jpg.ico";
 }
And 4. There are many syntax errors. You should really read the scripting guide.
paste this code into XYplorer's addressbar and press ENTER to open the relevant manual page.

Code: Select all

::help 'idh_scripting.htm';
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

strettonbull
Posts: 2
Joined: 23 Mar 2017 10:53

Re: Icon Help

Post by strettonbull »

Thank you very much. I told you I was new to this!

I'll get reading the script documentation.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Icon Help

Post by bdeshi »

Sorry if I sounded a little harsh. Happy reading! :D
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply