Skip to main content

Topic: short question about foo-script (Read 1627 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • seaeye
  • [*][*]
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!

  • Yotsuya
  • [*][*][*][*][*]
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.
  • Last Edit: 02 April, 2007, 07:29:34 PM by Yotsuya

  • seaeye
  • [*][*]
short question about foo-script
Reply #2
thanks a lot for the reply. i'm slowly figuring it out...