Check if DIRECTORY exists?
Posted: 03 Nov 2014, 21:35
I am new to Ventuz and working on a personal project to help me learn. I am doing the obligatory Music (Now Playing) Visualizer. I have tons of art that I have procured over some time that I can use for this project. Currently, I am working with ARTIST 'fanart' where I am trying to load-in 3 random pieces of fanart of the currently-playing ARTIST into a background scene from a specific directory. In my project\images folder I have made a copy of my MUSIC ART folder that contains subdirectories categorized by ARTIST NAME. These subfolders contain a thumbnail of the ARTIST (folder.jpg), BANNER ART (banner.jpg), LOGO ART (logo.png), and CDArt (cdart.png - images of the album disc art), etc.
Most of the time, but not all of the time (depending upon how obscure the artist is), there is another subfolder named EXTRAFANART that contains the images that I am currently trying to work with. I am able to load-in these images, as well as check for their existence AFTER I load them into an array. I'd like a more elegant solution where I can check to see if the EXTRAFANART folder exists BEFORE I load it into an array. Ventuz throws errors otherwise.
More specifically, I am using the NOW PLAYING ARTIST as a String variable and creating the following (A+B+C) expression:
A = .\Images\Music Library Art\
B = @ARTIST (Artist name loaded dynamically from currently-playing song)
C = \extrafanart\ (folder that may, or may not exist that contains the background art)
RESULT = .\Images\Music Library Art\[@ARTIST]\extrafanart\
It would be at this point where I'd like to check the URI for the existence of the EXTRAFANART folder, but I have not yet found a way to do that using the URL node directly- or indirectly-connected to this expression. The way I am able to do this checking process is to take the resulting expression path and plug it into a DIRECTORY node that reads *.jpg into an array and creates a resulting RESULTARRAY, COUNT and URI. I am then able to use the URL node to check if there exists any files (more specifically, it looks like it checks if there exists a .JPG as the first item) and throws an EXISTS flag as the result. It'd be easier if the fanart filenames were predictable, but these came from a database and the .jpg filenames are arbitrary. So, basically at this point, I am loading-in null items into the array if the folder is not there and I'd like to find a way to avoid this, if possible.
Most of the time, but not all of the time (depending upon how obscure the artist is), there is another subfolder named EXTRAFANART that contains the images that I am currently trying to work with. I am able to load-in these images, as well as check for their existence AFTER I load them into an array. I'd like a more elegant solution where I can check to see if the EXTRAFANART folder exists BEFORE I load it into an array. Ventuz throws errors otherwise.
More specifically, I am using the NOW PLAYING ARTIST as a String variable and creating the following (A+B+C) expression:
A = .\Images\Music Library Art\
B = @ARTIST (Artist name loaded dynamically from currently-playing song)
C = \extrafanart\ (folder that may, or may not exist that contains the background art)
RESULT = .\Images\Music Library Art\[@ARTIST]\extrafanart\
It would be at this point where I'd like to check the URI for the existence of the EXTRAFANART folder, but I have not yet found a way to do that using the URL node directly- or indirectly-connected to this expression. The way I am able to do this checking process is to take the resulting expression path and plug it into a DIRECTORY node that reads *.jpg into an array and creates a resulting RESULTARRAY, COUNT and URI. I am then able to use the URL node to check if there exists any files (more specifically, it looks like it checks if there exists a .JPG as the first item) and throws an EXISTS flag as the result. It'd be easier if the fanart filenames were predictable, but these came from a database and the .jpg filenames are arbitrary. So, basically at this point, I am loading-in null items into the array if the folder is not there and I'd like to find a way to avoid this, if possible.