First time poster - long time reader (OK not all that long, but so far this had been very helpful.)
I am looking to create a simple folder action that unzips a file anytime a new file is placed into the folder. So far, this is what I have (and its not working as expected)
on adding folder items to this_folder after receiving added_items
tell application
(get files whose name ends with ".gz") open
end tell
end adding folder items to
Ideally the script would look for .gz or .zip extensions. Any help would be greatly appreciated
I haven’t tested this, but it should be close:
on adding folder items to this_folder after receiving added_items
repeat with eachitem in added_items
if (name of eachitem) ends with ".gz" then
open eachitem
end if
end repeat
end adding folder items to
Come to think of it, you’d probably be better off moving the file to another folder and then opening it. That way the script won’t be called a second time when the compressed file(s) appear in the folder.
Is there a shell script that can be run to unzip the contents to a different location?
Anyone?
You could work this into my script above:
tell application "Finder"
set source_folder to choose file
set source_path to quoted form of (POSIX path of source_folder)
set Destination_folder to choose folder
set Destination_path to quoted form of (POSIX path of Destination_folder)
end tell
set command to "unzip " & source_path & " -d " & Destination_path
do shell script command