Created
August 11, 2025 15:07
-
-
Save waqashassan98/6107957cc9efbe2d45b44ce894f7cb64 to your computer and use it in GitHub Desktop.
Parse folders recursively and list all the images in it
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
#!/bin/bash | |
echo "folder,files" | |
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | while read filepath; do | |
dir=$(dirname "$filepath") | |
file=$(basename "$filepath") | |
echo "$dir,$file" | |
done | sort | awk -F, ' | |
{ | |
files[$1] = (files[$1] == "" ? $2 : files[$1]","$2) | |
} | |
END { | |
for (folder in files) { | |
print folder","files[folder] | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment