Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit 68ea951

Browse files
authored
Now the AppleScript is read and write
Release V8
1 parent e6b717a commit 68ea951

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

main.scpt

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Version "1.1" Icnspack-Builder Copyright (c) 2020,chris1111 All right reserved
2+
3+
use AppleScript version "2.4" -- Yosemite (10.10) or later
4+
use scripting additions
5+
-- Properties configuting the droplet shell
6+
property appletDropImage : "IMGDocumentIcon"
7+
property appletDropName : "Drop your Image files here"
8+
property appletSearchName : "Find Image files"
9+
property appletSearchImage : "IMGBadge"
10+
global appletIsQuitting
11+
12+
--on appletFileIsAcceptable(theFile)
13+
-- return true
14+
--end appletFileIsAcceptable
15+
on open dropped_files
16+
17+
18+
do shell script "afplay '/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/System/payment_success.aif' &> /dev/null &"
19+
do shell script "rm -rf /tmp/Resource"
20+
do shell script "rm -rf /tmp/Icon"
21+
do shell script "rm -rf /tmp/Resource.zip"
22+
do shell script "mkdir -p /Private/tmp/Resource"
23+
do shell script "mkdir -p /Private/tmp/Icon"
24+
log "theFiles" & dropped_files
25+
26+
set countFiles to count of dropped_files
27+
try
28+
set progress total steps to countFiles
29+
set progress completed steps to 0
30+
set progress description to "Processing images with Optimization! Wait…"
31+
delay 2
32+
display dialog "
33+
Ready to proceed and create the themes.
34+
An output ZIP file will be created (Resource.zip)" with icon note buttons {"Ready"} default button {"Ready"}
35+
{"Ready"}
36+
tell application "Icnspack-Builder"
37+
activate
38+
end tell
39+
40+
set progress additional description to "Ready"
41+
set steps to 0
42+
repeat with aFile in dropped_files
43+
set steps to steps + 1
44+
set progress completed steps to steps
45+
set progress additional description to (name of (info for aFile)) & " (" & steps & "/" & countFiles & ")"
46+
delay 0.2 --1.0E-3
47+
end repeat
48+
49+
display alert "Files Dropped!" message (countFiles as text) giving up after 1
50+
51+
## Set use_terminal to true to run the script in a terminal
52+
set use_terminal to true
53+
## Set exit_terminal to true to leave the terminal session open after script runs
54+
set exit_terminal to true
55+
## Set log_file to a file path to have the output captured
56+
set file_list to ""
57+
set theFonts to dropped_files
58+
repeat with f in theFonts
59+
set fposix to the quoted form of the POSIX path of f
60+
do shell script "rsync " & fposix & " /tmp/Icon"
61+
end repeat
62+
set the_command to quoted form of POSIX path of (path to resource "icnspack-Build" in directory "Scripts")
63+
64+
repeat with file_path in dropped_files
65+
set file_list to file_list & " " & quoted form of POSIX path of file_path
66+
end repeat
67+
set the_command to the_command & " " & file_list
68+
try
69+
if log_file is not missing value then
70+
set the_command to the_command & " | tee -a " & log_file
71+
end if
72+
end try
73+
try
74+
set use_terminal to false
75+
end try
76+
if not use_terminal then
77+
78+
do shell script "afplay '/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/System/Volume Unmount.aif' &> /dev/null &"
79+
do shell script the_command
80+
set progress additional description to "Build Done!"
81+
delay 1
82+
display alert "The images have been transformed into Icons" buttons "Done" default button "Done" giving up after 5
83+
set theAction to button returned of (display dialog "
84+
Please select a destination to save the file Resource.zip
85+
86+
NOTE: If you have already a Resource.zip in this location, you must move it or rename to save another one otherwise it will be replaced." with icon note buttons {"Save"} default button {"Save"})
87+
{"Save"}
88+
if theAction = "Save" then
89+
end if
90+
91+
tell application "Finder"
92+
set sourceFolder to (POSIX file "/Private/tmp/Resource.zip") as alias
93+
set DestFolder to choose folder with prompt "Choose destination Location" default location (path to desktop)
94+
duplicate sourceFolder to folder DestFolder with replacing
95+
end tell
96+
delay 0.5
97+
set myFile to "/Private/tmp/Resource.zip"
98+
try
99+
do shell script "rm -rf " & quoted form of myFile
100+
end try
101+
end if
102+
end try
103+
104+
end open

0 commit comments

Comments
 (0)