Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7918205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:25:37+00:00 2026-06-03T15:25:37+00:00

I am creating an applescript that creates a backup image of the /Users folder

  • 0

I am creating an applescript that creates a backup image of the /Users folder in Mac Os X. I would like to do one of two things:

  1. Either display a barber pole progress bar while the shell script is running with an option to quit.
  2. Display a dialog box while the script is running with an option to quit.

I have tried doing the shell script with the /dev/null but that ignores all output. I would like to save the output and display it in a dialog for the user.

Here is my code:

set computername to (do shell script "networksetup -getcomputername")
set fin to ""
set theIcon to note
tell application "Finder"
    try
        set folderalias to "/Users"
        set foldersize to physical size of folder (alias ":Users") --(info for folderalias) 
        set foldersize to (round ((foldersize / 1.0E+9) * 100)) / 100
    on error
        tell application "System Events"
            set foldersize to (round (((get physical size of folder ":Users" as text) / 1.0E+9) * 100)) / 100
        end tell
    end try
end tell

display dialog "User profile backup utility" & return & return & ¬
    "The computer name is: " & computername & return & return & ¬
    "The '/Users/' directory size is: " & "~" & foldersize & " GB" & return & return & ¬
    "Would you like to backup the '/User' directory now?" & return ¬
    buttons {"Cancel", "Backup Now"} default button "Backup Now"
set comd to "hdiutil create ~/Desktop/" & computername & ".dmg -srcfolder /test/"
set fin to do shell script (comd) with administrator privileges
display dialog fin
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:25:40+00:00Added an answer on June 3, 2026 at 3:25 pm

    Displaying a progress bar dialog is not possible with on-board AppleScript (i.e. Standard Additions), but this can be achieved using Shane Stanley’s ASObjC Runner, a scriptable faceless background application which provides, among many over useful functions, a set of progress dialog related commands. Once downloaded onto your system,

    tell application "ASObjC Runner"
        reset progress
        set properties of progress window to {button title:"Abort Backup", button visible:true, message:"Backing up the '" & (POSIX path of folderalias) & "' directory.", detail:"There are " & foldersize & " GB of data to backup – this might take some time.", indeterminate:true}
        activate
        show progress
    end tell
    try -- to make sure we destroy the dialog even if the script error out
        <your backup operation here>
    end try   
    tell application "ASObjC Runner" to hide progress
    

    will show an indeterminate progress bar (or “barber pole”) while the backup operation runs – at least if it is synchronous (as shell commands called from AS are). As to the output of your shell command, that is automatically returned by the do shell script command – in your code, it is assigned to fin [code lifted more or less wholesale from the ASObjC Runner documentation].

    ASObjC Runner can be embedded into an AppleScript application (save your script as an application in AppleScript Editor) by putting it into the bundle’s Resources folder (in Finder, select Show Package Contents in the context menu) and using the path to resource command to call it inside a using terms from block – the documentation I linked to above has details and example code, but, crucially, contains one critical error: your tell statement needs to use the POSIX path to the Resources bundle (tell application (POSIX path of (path to resource "ASObjC Runner.app"))).

    A few remarks on your code:

    • there is a more elegant way to get an alias to the /Users folder:

      path to users folder
      

      – no need for hardwiring and calls to Finder. You can then get the shell compatible path to that by using POSIX path of, or, if you need it quoted, quoted form of POSIX path of of it.

    • I’d recommend using only System Events to get the physical size – unlike Finder, it works in the background. That will allow you to get rid of the tell application "Finder" and try … catch blocks (not sure what you meant to achieve by that one anyway – if you were reacting to error -10004, that is because round does not like to be put inside a tell block).
    • No need to initialize fin to an empty string – you will get a return value from do shell script.
    • Speaking of your do shell script, you need to quote the computerName variable of it will break on spaces in that name.
    • theIcon is never used.
    • You might want to use display alert instead of display dialog for the user confirmation, as it has a nice emphasis on the first part of the message.
    • There are a lot of unnecessary parentheses in the code – AppleScript needs some of these to delimit semantic command blocks, but not all of them…

    All together mean your code can be modified to:

    set computerName to do shell script "networksetup -getcomputername"
    set folderAlias to path to users folder
    tell application "System Events" to set folderSize to physical size of folderAlias
    set folderSize to round(folderSize / 1.0E+9 * 100) / 100
    
    display alert "User profile backup utility" message ¬
      "The computer name is: " & computerName & return & return & ¬
      "The '" & (POSIX path of folderAlias) & "' directory size is: " & "~" & folderSize & " GB" & return & return & ¬
      "Would you like to backup the '" & (POSIX path of folderAlias) & "' directory now?" & return ¬
      buttons {"Cancel", "Backup Now"} default button "Backup Now"
    set shellCmd to "hdiutil create ~/Desktop/'" & computerName & "'.dmg -srcfolder /test/"
    -- progress bar dialog display initialization goes here
    try
        set shellOutput to do shell script shellCmd with administrator privileges
    end try
    -- progress bar dialog hiding goes here
    display dialog shellOutput
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about creating an AppleScript command that when I just run
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
I am creating an application using AppleScript and I want to display a list
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating an installer for possible remote systems so that if they do not have
creating 20 viewcontrollers and calling them one after the other from the mainviewcontroller as
Creating a C# install package and I'd like on completed install for the Program
Creating simple php login scripts is easy, with simple one table mysql integration. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.