Skip to content

Instantly share code, notes, and snippets.

@TomSoderling
Last active December 18, 2018 20:39
Show Gist options
  • Save TomSoderling/2c473b6d65f4cede805077a5cdf3030b to your computer and use it in GitHub Desktop.
Save TomSoderling/2c473b6d65f4cede805077a5cdf3030b to your computer and use it in GitHub Desktop.
Bash script for cleaning out the Xcode archives folder
#!/bin/bash
# Script to clean out the old archives found in the Xcode/Archives folder
# Variables
archivesFolder="/Users/[your username goes here]/Library/Developer/Xcode/Archives"
echo "*******************************************************"
echo "* Xcode Archives Cleaner 2000"
echo "*******************************************************"
echo "Archives folder: " $archivesFolder
# make sure the folder is there
if [ -e $archivesFolder ]
then
echo "Archives folder found"
else
echo "Archives folder not found"
exit 1 # exit with unspecified error code
fi
# check if folder has any items in it
if [ -z "$(ls $archivesFolder)" ] # -z: The length of string is zero
then
echo "Folder is empty"
exit 1 # exit with unspecified error code
else
echo "Folder is not Empty"
ls -l $archivesFolder
# delete anything in the Archives folder
rm -r $archivesFolder/*
echo "Archives folder cleaned"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment