#!/bin/bash # Create the target directory if it doesn't exist mkdir -p ../all # Use find and xargs to move jpg files from all chunk directories find ./chunk_* -name "*.jpg" -print0 | xargs -0 mv -t ../all/