Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: short question about foo-script (Read 2048 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

short question about foo-script

hi guys.
pardon a lame question about scripting, but i've just started. I want to touch on of the exisitng .pui files and adjust the source of cover files.

the logic is as follows:
- if there's a JPG file in the parent dir, where files are stored, grab it;
- else search in a fixed location a JPG file, which name starts with the name of the album played.

something like...

Code: [Select]
$setpvar(coverartsrc,
$if($fileexists($replace(%path%,%filename_ext%,*.jpg)),
$replace(%path%,%filename_ext%,*.jpg),
C:/covers/%album%*.jpg
)
)


but it doesn;t work properly. what am i missing here?
thanks!

short question about foo-script

Reply #1
Try something like this:
Code: [Select]
// PerTrack
$puts(coverartsrc,$replace(%path%,%filename_ext%.*.jpg))

$setpvar(coverartsrc,$if($fileexists($get(coverartsrc)),$get(coverartsrc),
c:\covers\%album%*.jpg
))


I don't really see a problem with the code you pasted unless it is not under a // PerTrack or // PerSecond header. Also, I assume by your example that by "parent dir" you are referring to the directory that the song file resides in. If you actually mean the parent directory 1 level higher, replace "%filename_ext%" with "%directory%\%filename_ext%". Also there is support for wildcard extensions so you can replace ".jpg" with ".*" and the code will automatically search for .gif, .png, etc.

short question about foo-script

Reply #2
thanks a lot for the reply. i'm slowly figuring it out...