• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版ee6bcfedd89039e68973a8b0d58acef89d3d6147 (tree)
时间2015-03-31 18:38:00
作者MD5500 <edktsnr@yaho...>
CommiterMD5500

Log Message

fix1

更改概述

差异

--- a/cycle_save.applescript
+++ b/cycle_save.applescript
@@ -1,74 +1,43 @@
11 (*
22 2012-08-27 v1.0
3- 2012-09-06 v1.1 ドキュメント修正時のみ保存
4- 2014-06-23 v1.2 アプリケーションの終了時に付随して終了させる
3+ 2015-03-31 v1.1 ファイルパスがalias値で返ってこないのに対応
54 *)
5+property waitTime : 15 --分単位
66
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
1510 end idle
1611
1712
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-
3513 on main()
3614 tell application "Adobe Illustrator"
3715 if (count of document) is not 0 then
38- set flg_doc to 0
16+ set flg_doc to false
3917 tell current document
4018 set doc_name to name
4119 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
4425 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+
4728 end try
4829 end tell
4930
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)
6535 end if
6636
6737 end if
6838 end tell
6939 end main
7040
71-
7241 on doc_save(doc_path)
7342 tell application "Adobe Illustrator"
7443 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)
7746 end doc_save
7847
7948 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+*)
8063 set p_doc_path to POSIX path of doc_path
8164 set new_doc_path to my Delimiters(p_doc_path, doc_name, "") & "_version/" & my Delimiters(doc_name, ".ai", "") & "_" & my DateToString() & ".ai"
8265
@@ -97,6 +80,6 @@ end Delimiters
9780
9881
9982 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"
10184 return (todayStr)
102-end DateToString
\ No newline at end of file
85+end DateToString
--- /dev/null
+++ b/cycle_save_onquit.applescript
@@ -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