How can I make AppleScript do two things at the same time?


I’ve been working on my first application with Apple Script. It’s a simple back up program for myself. Just an attempt to figure it all out.

I ran into this problem where i want to backup (copy) my folders and show a progress Indicator.
Here is a litte bit of the script. I’m dutch so that’s why you may see some words you don’t understand.

		if PREFAPP = "true" then
                      -- Just setting the on screen messages right.
			set contents of text field "progressStatus" to "Backuppen: Programma's"
			set contents of text field "progressText" to "Grootes berekenen..."
			update window of theObject

                     -- In this case i'd liketo backup my Applications folder.
                     -- First i want to know the data size.
			set APPSIZE to do shell script "du -ks /Applications | awk '{print $1}'"
			set maximum value of progress indicator "progressBar" to APPSIZE
			set VALUE to 0
			set contents of text field "progressStatus" to "Backuppen: Programma's"
			-- Make the copy
			do shell script "cp -r /Applications " & BACKUPLOCATION & ""

				-- Check the data size of the destinationfolder
				set VALUE to do shell script "du -ks " & BACKUPLOCATION & " | awk '{print $1}'"
				set content of progress indicator "progressBar" to VALUE
				set contents of text field "progressText" to "Bytes gekopieerd: " & VALUE & " van " & APPSIZE & ""
				update window of theObject
				if VALUE > APPSIZE then exit repeat
			end repeat
			set APPSIZE to 0
		end if

Now when i do this the applescript is waiting until it already copied the applications folder.
And when done it fails into the repeat.
But i want it to copy while running the repeat.
Is there is statement that says "while doing this (copying) do that. "
Or is there another way?

Thanks in advance.


Try making the cp command run in the background:

 do shell script "cp -r /Applications " & BACKUPLOCATION & " &"

Thanks good idea.
Although it didn’t work.

Maybe send every output to dev null?


I fixt it.
I had to run it in the background but as well write everything away to dev/null!