Skip to content

Instantly share code, notes, and snippets.

@waqashassan98
Created August 11, 2025 15:07
Show Gist options
  • Save waqashassan98/6107957cc9efbe2d45b44ce894f7cb64 to your computer and use it in GitHub Desktop.
Save waqashassan98/6107957cc9efbe2d45b44ce894f7cb64 to your computer and use it in GitHub Desktop.
Parse folders recursively and list all the images in it
#!/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