Skip to content

Instantly share code, notes, and snippets.

@kolanski
Created June 28, 2024 15:25
Show Gist options
  • Save kolanski/91e7ac9a2c9c3359feaebfea92acf72b to your computer and use it in GitHub Desktop.
Save kolanski/91e7ac9a2c9c3359feaebfea92acf72b to your computer and use it in GitHub Desktop.
Turn folders on Mac with preview for Kenney assets
# first in sh - brew install fileicon
# then input path to folder 2d assets or 3d assets
import os
from subprocess import call
def set_directory_preview(root_dir):
for subdir, dirs, files in os.walk(root_dir):
for file in files:
if file == 'Preview.png' or file == 'Preview1.png' or file == 'Sample.png': # Name of the preview file
preview_path = os.path.join(subdir, file)
# Set the directory preview
call(['fileicon', 'set', subdir, preview_path])
print(f'Set preview for {subdir}')
break # Stop searching this directory after finding a preview
if __name__ == "__main__":
root_directory = input("Enter the root directory path: ")
set_directory_preview(root_directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment