Skip to content

Instantly share code, notes, and snippets.

@eguneys
Created June 18, 2023 20:29
Show Gist options
  • Save eguneys/5fd540f5506423e5384f26bd6fb742c1 to your computer and use it in GitHub Desktop.
Save eguneys/5fd540f5506423e5384f26bd6fb742c1 to your computer and use it in GitHub Desktop.
extract files in all folders into a single folder.
tmp_dir="/tmp/xyz_data"
mkdir -p "$tmp_dir"
for folder in "$source_dir"/*; do
if [ -d "$folder" ]; then
folder_name=$(basename "$folder")
cp "$folder"/* "$tmp_dir"
fi
done
mv "$tmp_dir" "$destination_dir"
count=$(ls -p "$destination_dir" | grep -v / | wc -l)
echo "done $count files."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment