Skip to content

Instantly share code, notes, and snippets.

@ryanmaclean
Last active October 12, 2016 18:15
Show Gist options
  • Save ryanmaclean/ab71e3f9b8dda7ed0a5de15b52e252c2 to your computer and use it in GitHub Desktop.
Save ryanmaclean/ab71e3f9b8dda7ed0a5de15b52e252c2 to your computer and use it in GitHub Desktop.
Traverse directories, mount ISOs and copy files out of them
#!/bin/bash
printf '\e[31m *** This command will traverse subfolders ***\e[0m\n'
printf '\e[31m *** and mount each ISO found and copy the contents ***\e[0m\n'
printf '\e[31m *** to the directory of the ISO, then unmount the ISO ***\e[0m\n'
printf '\e[31m *** and delete it permanently. ***\e[0m\n'
read -r -p "Are you sure you would like to proceed? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
for i in $(ls -d */)
do
cd $i
echo "Entering "$i
if hdiutil attach *.iso; then
echo "Copying files"
rsync -ah --progress /Volumes/CDROM/ .
hdiutil detach /Volumes/CDROM
echo "Removing ISO from "$i
rm *.iso
echo "Returning to initial folder"
cd ..
else
cd ..
printf "Either "$i"\nalready completed, or no ISO found"
fi
done
;;
*)
echo -e "\e[32mExiting now\e[0m"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment