Skip to content

Instantly share code, notes, and snippets.

@macmule
Created November 21, 2021 15:39
Show Gist options
  • Select an option

  • Save macmule/580c29bdc0236c2de54e4e2558db147e to your computer and use it in GitHub Desktop.

Select an option

Save macmule/580c29bdc0236c2de54e4e2558db147e to your computer and use it in GitHub Desktop.
-- Get the name Volume Name of the Macs CoreStorage volume.
set csVolume to do shell script "diskutil cs list | awk '/Volume Name:/{out=$3; for(i=4;i<=NF;i++){out=out\" \"$i}; print out}'"
-- If the above command come back with a Volume Name.
if csVolume is not "" then
-- Set this app to the front
tell application "System Events" to set frontmost of process "CoreStorage Revert" to true
-- Advise that volume needs to be reverted, offering option to skip if wanted
display dialog "The volume " & csVolume & " is a CoreStorage volume & needs to be reverted to image this Mac." & return & return & "Do you wish to revert?" & return & return & "Once reverted Casper Imaging will launch." buttons {"Skip", "Revert"} with title "CoreStorage volumes detected" with icon 2 default button "Revert"
-- If user chose to skip, then run the launchCasperImaging function
if button returned of the result is "Skip" then
my launchCasperImaging()
else
-- Revert the Core Storage volume
do shell script "diskutil coreStorage revert /Volumes/" & quoted form of csVolume
-- Run the launchCasperImaging function
my launchCasperImaging()
end if
else -- If the 1st command came back with no value, this means that no volumes have CoreStorage enabled
-- Run the launchCasperImaging function
my launchCasperImaging()
end if
-- This function will launch Casper Imaging & quit this app.
on launchCasperImaging()
tell application "Casper Imaging" to launch
tell me to quit
end launchCasperImaging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment