FolderLink is asset made with Xpresso and Python that allows you to select folder which includes specific file types. You can decide which kind of file types you are looking for by typing file extensions (separated with comma). FolderLink will scan selected folder (top level) and collects approved files to dropdown menu.

Then you can link easily and quickly browse between different files with dropdown menu and link selected file’s file path to whatever you like, for example to textures or HDRIs.

import c4d, os # Import necessary libraries

def main():
    global path # Output file path
    string = search # Get extensions string
    string = search.replace(" ","") # Remove spaces
    extensions = string.split(",") # Split to list
    c = 0 # Initialize iteration variable
    names = [] # Initialize list for file names
    obj = doc.SearchObject("FolderLink")
    cycle = c4d.BaseContainer() # Initialize base container
    bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG) # Integer
    bc.SetString(c4d.DESC_NAME, "File") # Set user data name
    bc.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_CYCLE) # Set user data gui
    try: # Try to execute following code
        if folder != "": # If there is folder
            files = os.listdir(folder) # Get files from folder
            for f in files: # Iterate through files
                ext = f.rsplit(".",1) # Get file extension
                if ext[1] in extensions: # If file extension matches
                    c += 1 # Increase iteration
                    cycle.SetString(c, f) # Add item to user data cycle
                    names.append(f) # Add file name to list
            bc.SetContainer(c4d.DESC_CYCLE, cycle) # Set container
            obj.SetUserDataContainer([c4d.ID_USERDATA, 5], bc) # Update user data
            path = folder+"\\"+names[select-1] # Return file path
        else: # Else
            path = "" # Return empty string
    except IndexError: # If something went wrong
        path = "" # Return empty string

If you use Mac OS X you might have to change line 26 “\\” to “/”.
I updated the file so now it’s possible to filter files by filename extension. Thanks to @lasse_lauch for this suggestion.

ar_xpresso_folderlink.c4d v1.0.0 (2023.1.2)

Asset, Cinema 4D, Python, Xpresso