Created
June 28, 2024 15:25
-
-
Save kolanski/91e7ac9a2c9c3359feaebfea92acf72b to your computer and use it in GitHub Desktop.
Turn folders on Mac with preview for Kenney assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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