r/zsh • u/CharlieJP102 • 8h ago
Finding files by extension and copying them to a folder
On a 2021 Mac, I would like to run a shell script that searches all the folders in the current directory and all folders under those folders for files ending in the following (include upper and lower case variants): heic, jpg, and jpeg
Copy files matching those extensions into a folder named POST in the current directory.
Thanks for your attention to this.
Gemini suggests this but I don't trust it. :-)
mkdir -p POST find . -path ./POST -prune -o -type f \( -iname "*.heic" -o -iname "*.jpg" -o -iname "*.jpeg" \) -exec cp -n {} POST/ \;