修订版 | ee6bcfedd89039e68973a8b0d58acef89d3d6147 (tree) |
---|---|
时间 | 2015-03-31 18:38:00 |
作者 | MD5500 <edktsnr@yaho...> |
Commiter | MD5500 |
fix1
@@ -1,74 +1,43 @@ | ||
1 | 1 | (* |
2 | 2 | 2012-08-27 v1.0 |
3 | - 2012-09-06 v1.1 ドキュメント修正時のみ保存 | |
4 | - 2014-06-23 v1.2 アプリケーションの終了時に付随して終了させる | |
3 | + 2015-03-31 v1.1 ファイルパスがalias値で返ってこないのに対応 | |
5 | 4 | *) |
5 | +property waitTime : 15 --分単位 | |
6 | 6 | |
7 | -property wait_Time : 10 --分 保存する間隔 | |
8 | -property idle_Time : 2 --秒 プロセス監視の間隔 | |
9 | -property elapsed_Time : 0 --前回保存時よりの経過時間 | |
10 | - | |
11 | -on idle | |
12 | - my watch_ill() | |
13 | - | |
14 | - return idle_Time | |
7 | +on idle {} | |
8 | + my main() | |
9 | + return waitTime * 60 | |
15 | 10 | end idle |
16 | 11 | |
17 | 12 | |
18 | -on watch_ill() | |
19 | - try | |
20 | - do shell script "ps cx | grep Illustrator" | |
21 | - | |
22 | - if wait_Time * 60 - idle_Time is less than or equal to elapsed_Time then | |
23 | - my main() | |
24 | - set elapsed_Time to 0 | |
25 | - end if | |
26 | - | |
27 | - on error | |
28 | - quit --Illustratorが起動していない場合は終了 | |
29 | - end try | |
30 | - | |
31 | - set elapsed_Time to elapsed_Time + idle_Time | |
32 | - | |
33 | -end watch_ill | |
34 | - | |
35 | 13 | on main() |
36 | 14 | tell application "Adobe Illustrator" |
37 | 15 | if (count of document) is not 0 then |
38 | - set flg_doc to 0 | |
16 | + set flg_doc to false | |
39 | 17 | tell current document |
40 | 18 | set doc_name to name |
41 | 19 | try |
42 | - set doc_path to file path as Unicode text | |
43 | - set flg_doc to 1 | |
20 | + set doc_path to file path | |
21 | + set doc_path to (POSIX path of doc_path) as POSIX file | |
22 | + tell application "Finder" to set aFolder to parent of (doc_path as alias) as Unicode text | |
23 | + | |
24 | + set flg_doc to true | |
44 | 25 | on error |
45 | - display dialog "一度も保存されていないようです" buttons " OK " default button 1 giving up after 3 | |
46 | - return | |
26 | + display dialog "一度も保存されていないようです" buttons " OK " default button 1 | |
27 | + | |
47 | 28 | end try |
48 | 29 | end tell |
49 | 30 | |
50 | - if modified of current document is true then | |
51 | - | |
52 | - my doc_save(doc_path) | |
53 | - | |
54 | - if flg_doc is 1 then | |
55 | - try | |
56 | - --display dialog "doc_copy" | |
57 | - my doc_copy(doc_path, doc_name) | |
58 | - on error | |
59 | - --display dialog "make new folder" | |
60 | - tell application "Finder" to make new folder at (my Delimiters(doc_path, doc_name, "") as alias) with properties {name:"_version"} | |
61 | - my doc_copy(doc_path, doc_name) | |
62 | - end try | |
63 | - end if | |
64 | - | |
31 | + my doc_save(doc_path) | |
32 | + | |
33 | + if flg_doc then | |
34 | + my doc_copy(aFolder, doc_path, doc_name) | |
65 | 35 | end if |
66 | 36 | |
67 | 37 | end if |
68 | 38 | end tell |
69 | 39 | end main |
70 | 40 | |
71 | - | |
72 | 41 | on doc_save(doc_path) |
73 | 42 | tell application "Adobe Illustrator" |
74 | 43 | save current document in file doc_path as Illustrator with options {class:Illustrator save options, PDF compatible:false} |
@@ -77,6 +46,20 @@ on doc_save(doc_path) | ||
77 | 46 | end doc_save |
78 | 47 | |
79 | 48 | on doc_copy(doc_path, doc_name) |
49 | + (* | |
50 | + try | |
51 | + --display dialog "doc_copy" | |
52 | + --my doc_copy(doc_path, doc_name) | |
53 | + on error | |
54 | + --display dialog "make new folder" | |
55 | + tell application "Finder" to make new folder at (aFolder as alias) with properties {name:"_version"} | |
56 | + --my doc_copy(doc_path, doc_name) | |
57 | + end try | |
58 | + my doc_copy(aFolder, doc_path, doc_name) | |
59 | + end if | |
60 | + | |
61 | + end if | |
62 | +*) | |
80 | 63 | set p_doc_path to POSIX path of doc_path |
81 | 64 | set new_doc_path to my Delimiters(p_doc_path, doc_name, "") & "_version/" & my Delimiters(doc_name, ".ai", "") & "_" & my DateToString() & ".ai" |
82 | 65 |
@@ -97,6 +80,6 @@ end Delimiters | ||
97 | 80 | |
98 | 81 | |
99 | 82 | on DateToString() |
100 | - set todayStr to do shell script "date '+%m%d_%k%M'" --秒を追加する時はMのあとに%Sを追加 | |
83 | + set todayStr to do shell script "date +%m%d_%H%M" | |
101 | 84 | return (todayStr) |
102 | -end DateToString | |
\ No newline at end of file | ||
85 | +end DateToString |
@@ -0,0 +1,102 @@ | ||
1 | +(* | |
2 | + 2012-08-27 v1.0 | |
3 | + 2012-09-06 v1.1 ドキュメント修正時のみ保存 | |
4 | + 2014-06-23 v1.2 アプリケーションの終了時に付随して終了させる | |
5 | +*) | |
6 | + | |
7 | +property wait_Time : 10 --分 保存する間隔 | |
8 | +property idle_Time : 2 --秒 プロセス監視の間隔 | |
9 | +property elapsed_Time : 0 --前回保存時よりの経過時間 | |
10 | + | |
11 | +on idle | |
12 | + my watch_ill() | |
13 | + | |
14 | + return idle_Time | |
15 | +end idle | |
16 | + | |
17 | + | |
18 | +on watch_ill() | |
19 | + try | |
20 | + do shell script "ps cx | grep Illustrator" | |
21 | + | |
22 | + if wait_Time * 60 - idle_Time is less than or equal to elapsed_Time then | |
23 | + my main() | |
24 | + set elapsed_Time to 0 | |
25 | + end if | |
26 | + | |
27 | + on error | |
28 | + quit --Illustratorが起動していない場合は終了 | |
29 | + end try | |
30 | + | |
31 | + set elapsed_Time to elapsed_Time + idle_Time | |
32 | + | |
33 | +end watch_ill | |
34 | + | |
35 | +on main() | |
36 | + tell application "Adobe Illustrator" | |
37 | + if (count of document) is not 0 then | |
38 | + set flg_doc to 0 | |
39 | + tell current document | |
40 | + set doc_name to name | |
41 | + try | |
42 | + set doc_path to file path as Unicode text | |
43 | + set flg_doc to 1 | |
44 | + on error | |
45 | + display dialog "一度も保存されていないようです" buttons " OK " default button 1 giving up after 3 | |
46 | + return | |
47 | + end try | |
48 | + end tell | |
49 | + | |
50 | + if modified of current document is true then | |
51 | + | |
52 | + my doc_save(doc_path) | |
53 | + | |
54 | + if flg_doc is 1 then | |
55 | + try | |
56 | + --display dialog "doc_copy" | |
57 | + my doc_copy(doc_path, doc_name) | |
58 | + on error | |
59 | + --display dialog "make new folder" | |
60 | + tell application "Finder" to make new folder at (my Delimiters(doc_path, doc_name, "") as alias) with properties {name:"_version"} | |
61 | + my doc_copy(doc_path, doc_name) | |
62 | + end try | |
63 | + end if | |
64 | + | |
65 | + end if | |
66 | + | |
67 | + end if | |
68 | + end tell | |
69 | +end main | |
70 | + | |
71 | + | |
72 | +on doc_save(doc_path) | |
73 | + tell application "Adobe Illustrator" | |
74 | + save current document in file doc_path as Illustrator with options {class:Illustrator save options, PDF compatible:false} | |
75 | + --PDF互換にするにはPDF compatible:falseをtrueにする | |
76 | + end tell | |
77 | +end doc_save | |
78 | + | |
79 | +on doc_copy(doc_path, doc_name) | |
80 | + set p_doc_path to POSIX path of doc_path | |
81 | + set new_doc_path to my Delimiters(p_doc_path, doc_name, "") & "_version/" & my Delimiters(doc_name, ".ai", "") & "_" & my DateToString() & ".ai" | |
82 | + | |
83 | + set shellcmd to "cp -p " & quoted form of p_doc_path & " " & quoted form of new_doc_path | |
84 | + --display dialog shellcmd | |
85 | + do shell script shellcmd | |
86 | +end doc_copy | |
87 | + | |
88 | +on Delimiters(theText, serchStr, replaceStr) | |
89 | + set OriginalDelimiters to AppleScript's text item delimiters | |
90 | + set AppleScript's text item delimiters to serchStr | |
91 | + set theText to text items of theText | |
92 | + set AppleScript's text item delimiters to replaceStr | |
93 | + set theText to theText as string | |
94 | + set AppleScript's text item delimiters to OriginalDelimiters | |
95 | + return theText | |
96 | +end Delimiters | |
97 | + | |
98 | + | |
99 | +on DateToString() | |
100 | + set todayStr to do shell script "date '+%m%d_%k%M'" --秒を追加する時はMのあとに%Sを追加 | |
101 | + return (todayStr) | |
102 | +end DateToString | |
\ No newline at end of file |