This is just a little shell script I use from time, to recursively search all my directories, and find all files that end in .jpg, or jpeg
and move them to my /home/user/Pictures directory
I never really thought there was anything special about this script until I showed it to a friend.
He wondered why all the files that ended in .JPG and JPEG got moved as well. It's because I'm using "iname" instead of name.
iname does both uppercase and lowercase files.
and move them to my /home/user/Pictures directory
Code:
#!/bin/bash
# Directory to start the search
START_DIR="/path/to/start/directory"
# Destination directory
DEST_DIR="/home/$USER/Pictures"
# Find and move all .jpg and .jpeg files (case insensitive) to the destination directory
find "$START_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec mv {} "$DEST_DIR" \;
echo "All .jpg and .jpeg files have been moved to $DEST_DIR."
I never really thought there was anything special about this script until I showed it to a friend.
He wondered why all the files that ended in .JPG and JPEG got moved as well. It's because I'm using "iname" instead of name.
iname does both uppercase and lowercase files.
Last edited:

