How to get the right amount of delay / busy status of :
set zip_file to "path:to:foo.zip"
tell application "System Events"
open alias zip_file
delete alias zip_file
Delay isn’t precise I know but anyway… Its a static value in seconds.
The dropped directory from zip might have another name.
I think the easier way to go is in one line shell script with “;” and I get also the result (the unzipped file as string).
But I don’t like to use rm in this chain it’s too powerful and little mistakes cause already a big mess
Use do shell script and ditto. You can still use System Events for the deletion if you wish.
I wouldn’t use “;” for commands like these especially when they the second command only needs to run when the first exited successful.
First lets use a command return a non zero value (error).
do shell script "false" --result: error
Now lets use a command separator (could use newline as well).
do shell script "false ; echo yes" -- result: "yes"
As you can see when the first commands exists with a non-zero value, as shown in the first example, the second command is just executed. The return value of the last command is returned and it silence all errors in the previous commands.
Now let’s use the AND operator to combine two commands.
do shell script "false && echo yes" -- result: error
The second command is now only executed when the first command exited successfully. In the example above “echo yes” is never executed. Instead of silencing previous commands when an commands returns a non-zero value the script is stopped and that value is returned. In AppleScript you will always catch the right error. In pseudo code you’re looking for something like this:
do shell script "unzip $source $target && rm $source"
Wow, I solved in a One-liner and replacing 4 more operations
Anyway I saw, ditto or cp don’t overwrite folders but files. So it’s an incremental merging, no real overwriting.
@DJ Bazzie Wazzie
Nice bits of wisdom. After a bit of testing, no command was able to give me the result of open (=> dropped files) but I solved with isolating in temporary items
I found no way around to get the amount of time that open needs to decompress a rar
Fortunately, rar didn’t matter for the final outcome of my code, so zip were used instead.