Tiny asset cataloguing utility

8InchFloppyDick

Member
Game Developer
Apr 4, 2020
135
385
Dear All,

Over the past while I've collected a respectable pile of DAZ assets which I store in a simple folder structure organised by theme. For example:

characters -> 00_creatures -> 00_dragons

However, on Windows in particular it can be hard to see the jpg images of the asset, as the windows explorer 'extra large icon' size isn't that large. Making it hard to browse/choose assets. To alleviate this issue I hacked together a trivial python script that walks the folders of a directory and pulls any jpg files out of those folders and dumps them into a single folder called '00_catalogue'.

Please note that the '00_catalogue' folder needs to be created by hand and the script should be run from a command line.

After running the script I then enter the '00_catalogue' folder and use to browse the asset images.

Anyhow, this setup works well for me so I thought I'd share it. Perhaps it might be useful to others.

NOTE: The script uses os.scandir() so you'll need Python 3.5 or later to run it.

Code:
# catalogue.py       Primitive DAZ asset cataloguing utility.
#
#                    The 00_catalogue folder needs to exist.
#                    Was too lazy to add the half a line of code to
#                    check/create the destination folder.
#
#                    (c)2020 under GPL - 8InchFloppyDick @f95zone.com

import os

CURRENT_DIR = os.getcwd()
CATALOGUE_DIR = CURRENT_DIR + "\\00_catalogue\\"

for entry in os.scandir(CURRENT_DIR):

    if entry.is_dir() and not entry.name[0:2] == "00":

        for thing in os.scandir(entry.name):

            filename, file_extension = os.path.splitext(thing.name)
           
            if (file_extension == ".jpg"):

                # sanitise filename
                filename = filename.replace("-00-main-", "")
                filename = filename.replace("00-main-", "")
                filename = filename.replace("-00-main", "")
                filename = filename.replace("_main", "")
                filename = filename.replace("-daz3d", "")
                filename = filename.replace("daz3d-", "")
                filename = filename.replace("00-daz3d_", "")
                filename = filename.replace("daz3d_", "")
                filename = filename.replace("daz3d", "")
                filename = filename.replace("product_image_", "")

                filename = filename + file_extension

                os.system('copy "' + os.path.abspath(thing) + '" "' + CATALOGUE_DIR + filename + '"')
 
  • Like
Reactions: Madmanator99

Madmanator99

Member
May 1, 2018
225
466
I can see how this can be usefull, althou, it seems to dump all the images in the same folder, how about developing it and making an html file with a grid populated by the pictures, and if you click on one of them, it opens the folder it was pulled from?

But I have to say, you did cover alot of the typical names of the pictures that come with the products. It worked well for me, except I have over 9k pictures now lol. So yeah, some kind of sorting would be very usefull. I understaind I'm not the typical user thou, and that this was not your goal, but just an idea ;)
You don't have permission to view the spoiler content. Log in or register now.
 
Last edited:

8InchFloppyDick

Member
Game Developer
Apr 4, 2020
135
385
it seems to dump all the images in the same folder how about developing it and making an html file with a grid populated by the pictures, and if you click on one of them, it opens the folder it was pulled from?
hehe, sorry for collating all your images in one place... It's a result of how I organise my assets according to theme in multiple directories. I have a 00_catalogue folder in each one of them. I think my largest set of images is just under 1k in a dir. You are of course right about the file duplication. Basically, I just wanted to keep things super imple on the viewing end by being able to keep using QuickLook+Win10 File explorer.

On the other hand, your idea of having an HTML index is quite sensible. Maybe I'll give it a go one of these days as I wait for some renders to cook.

Thanks for taking an interest!
 
  • Like
Reactions: Madmanator99

8InchFloppyDick

Member
Game Developer
Apr 4, 2020
135
385
Couldn't sleep, so added some Qualifty-of-Life updates to my trivial catalogue script.

Code:
# catalogue.py         Primitive DAZ asset catalogue utility.
#
#                    v0.2 - added destination file existence check
#                         - added catalogue dir auto-creation
#                         - added 'promo' to filename filter
#
#                    (c)2020 under GPL - 8InchFloppyDick @f95zone.com

import os

CURRENT_DIR   = os.getcwd()
CATALOGUE_DIR = "00_catalogue"

catalogue_path = os.path.join(CURRENT_DIR, CATALOGUE_DIR)

if(not os.path.exists(catalogue_path)):
    
    os.mkdir(catalogue_path) 

    print("Catalogue directory '% s' created" % catalogue_path) 

else:
    
    print("Catalogue directory exists.")


for entry in os.scandir(CURRENT_DIR):

    if entry.is_dir() and not entry.name[0:2] == "00":

        for thing in os.scandir(entry.name):

            filename, file_extension = os.path.splitext(thing.name)
            
            if (file_extension == ".jpg"):

                # sanitise filename
                filename = filename.replace("-00-main-", "")
                filename = filename.replace("00-main-", "")
                filename = filename.replace("-00-main", "")
                filename = filename.replace("_main", "")
                filename = filename.replace("-daz3d", "")
                filename = filename.replace("daz3d-", "")
                filename = filename.replace("00-daz3d_", "")
                filename = filename.replace("daz3d_", "")
                filename = filename.replace("daz3d", "")
                filename = filename.replace("product_image_", "")
                filename = filename.replace("promo", "")

                filename = filename + file_extension

                destination = CATALOGUE_DIR + filename
                
                if (not os.path.exists(destination)):
                    
                    os.system('copy "' + os.path.abspath(thing) + '" "' + destination)
 
  • Like
Reactions: Madmanator99