老問題:中文檔名
版主: ross_tt、bryanchang、digdog、chester
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 macluo:
<STRONG>請問一下,編碼資料是放在那裡?有辦法看到嗎?我找了所有能檢視 file type, file info, data folk, resource folk 以及 Hex Editor 的程式。得到的結論是編碼資料不在檔案或檔案夾上面,難道是在 Desktop DB 或 Desktop DF 或另有別處?</STRONG><HR></BLOCKQUOTE>
在Carbon的API下,File Manager的其中一個function,FSGetCatalogInfoBulk,catalogInfos的argument會retu rn FSCatalogInfo這一個 structure,其中一個field是textEncodingHint,可以到Base Text Encodings裏查,每一個encoding還細分variations。
Cocoa我就不會了。 [img]images/smiles/icon_razz.gif[/img]
<STRONG>請問一下,編碼資料是放在那裡?有辦法看到嗎?我找了所有能檢視 file type, file info, data folk, resource folk 以及 Hex Editor 的程式。得到的結論是編碼資料不在檔案或檔案夾上面,難道是在 Desktop DB 或 Desktop DF 或另有別處?</STRONG><HR></BLOCKQUOTE>
在Carbon的API下,File Manager的其中一個function,FSGetCatalogInfoBulk,catalogInfos的argument會retu rn FSCatalogInfo這一個 structure,其中一個field是textEncodingHint,可以到Base Text Encodings裏查,每一個encoding還細分variations。
Cocoa我就不會了。 [img]images/smiles/icon_razz.gif[/img]
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 悲:
<STRONG>
短說:
眾裡尋它,編碼的資料就在文字裡。
長話:
OS 9 或前的系統,檔案或檔案夾的名稱是 styled text。意指名稱內含文字 ( ktxt 的部份 ),而 ksty 的部份則包含了字型,字體大小及風格如粗體、斜體及顏色等。重要的是,ksty 的字型資料暗地裡指示了編碼。
</STRONG><HR></BLOCKQUOTE>
依提供的 applescript 程式碼執行結果如下:
在 OS X 上能正常顯示中文的 big5 碼,其 class ksty 是
<<data styl0003000000000010000E40000000000C0000000000000000000A0010000E43100000000C0000000000000000000C0010000E40000000000C000000000000>>
在 OS X 顯示中文亂碼的 big5 碼,其 class ksty 是
<<data styl0001000000000010000E00030000000C000000000000>>
unicode 中文編碼,其 class ksty 是
<<data styl0001000000000010000E40000000000C000000000000>>
如果有中文亂碼的big5 檔名,只要用 applescript 將 <<class ksty>> 修正,應該就能解決在 OS X 上 big5 中文亂碼的問題嗎?
如果這個可行,那麼我一些上千個中文 big5 檔名在 OS X 的顯示問題就有解了。感謝~ [img]images/smiles/icon_biggrin.gif[/img]
<STRONG>
短說:
眾裡尋它,編碼的資料就在文字裡。
長話:
OS 9 或前的系統,檔案或檔案夾的名稱是 styled text。意指名稱內含文字 ( ktxt 的部份 ),而 ksty 的部份則包含了字型,字體大小及風格如粗體、斜體及顏色等。重要的是,ksty 的字型資料暗地裡指示了編碼。
</STRONG><HR></BLOCKQUOTE>
依提供的 applescript 程式碼執行結果如下:
在 OS X 上能正常顯示中文的 big5 碼,其 class ksty 是
<<data styl0003000000000010000E40000000000C0000000000000000000A0010000E43100000000C0000000000000000000C0010000E40000000000C000000000000>>
在 OS X 顯示中文亂碼的 big5 碼,其 class ksty 是
<<data styl0001000000000010000E00030000000C000000000000>>
unicode 中文編碼,其 class ksty 是
<<data styl0001000000000010000E40000000000C000000000000>>
如果有中文亂碼的big5 檔名,只要用 applescript 將 <<class ksty>> 修正,應該就能解決在 OS X 上 big5 中文亂碼的問題嗎?
如果這個可行,那麼我一些上千個中文 big5 檔名在 OS X 的顯示問題就有解了。感謝~ [img]images/smiles/icon_biggrin.gif[/img]
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote
"To change the style or font information for a styled text value, you must work with an application that knows how to manipulate styled text."
參看: http://developer.apple.com/techpubs/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/AppleScript.35.html#20600
但,有 Hex Editor 嗎?或繼續試驗,另尋方法?
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>在 OS X 顯示中文亂碼的 big5 碼,其 class ksty 是
<<data styl0001000000000010000E00030000000C000000000000>>
<HR></BLOCKQUOTE>
傳回的結果,這樣解釋:把 data styl 後的東西分成四個一組,共十一組,變成
0001 0000 0000 0010 000E 0003 0000 000C 0000 0000 0000
每組均為 HEX code,其中第六組為 font family ID,0003 為 geneva。
跟着比較另一個:
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>unicode 中文編碼,其 class ksty 是
<<data styl0001000000000010000E40000000000C000000000000>>
<HR></BLOCKQUOTE>
第六組為 4000,HEX code 4000 即是十進制的 16384。
有點頭緒嗎?
可惜不可,在 AppleScript Language Guide 內提及如果有中文亂碼的big5 檔名,只要用 applescript 將 <<class ksty>> 修正,應該就能解決在 OS X 上 big5 中文亂碼的問題嗎?
"To change the style or font information for a styled text value, you must work with an application that knows how to manipulate styled text."
參看: http://developer.apple.com/techpubs/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/AppleScript.35.html#20600
但,有 Hex Editor 嗎?或繼續試驗,另尋方法?
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>在 OS X 顯示中文亂碼的 big5 碼,其 class ksty 是
<<data styl0001000000000010000E00030000000C000000000000>>
<HR></BLOCKQUOTE>
傳回的結果,這樣解釋:把 data styl 後的東西分成四個一組,共十一組,變成
0001 0000 0000 0010 000E 0003 0000 000C 0000 0000 0000
每組均為 HEX code,其中第六組為 font family ID,0003 為 geneva。
跟着比較另一個:
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>unicode 中文編碼,其 class ksty 是
<<data styl0001000000000010000E40000000000C000000000000>>
<HR></BLOCKQUOTE>
第六組為 4000,HEX code 4000 即是十進制的 16384。
有點頭緒嗎?
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 悲:
<STRONG>
可惜不可,在 AppleScript Language Guide 內提及
"To change the style or font information for a styled text value, you must work with an application that knows how to manipulate styled text."
參看: http://developer.apple.com/techpubs/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/AppleScript.35.html#20600
但,有 Hex Editor 嗎?或繼續試驗,另尋方法?
</STRONG><HR></BLOCKQUOTE>
所有能在 OS 9 或 OS X 上找到的 Hex Editor 如
Resorcerer
Hexedit 1.8.5
Hexeditor
ResEdit (只能編 Resource fork)
等等
都只能編輯 Data fork 和 Resource fork 。而編輯 file attributes 的程式又沒有辦法對檔名之 styled text 施力。 如果 Mac 能有像 PCtools 那樣的 Hex editor ,說不定就有辦法。記得 Norton Utilities 有內附一個 Hex Editor ,不曉得這個可不可以做到。
<STRONG>
可惜不可,在 AppleScript Language Guide 內提及
"To change the style or font information for a styled text value, you must work with an application that knows how to manipulate styled text."
參看: http://developer.apple.com/techpubs/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/AppleScript.35.html#20600
但,有 Hex Editor 嗎?或繼續試驗,另尋方法?
</STRONG><HR></BLOCKQUOTE>
所有能在 OS 9 或 OS X 上找到的 Hex Editor 如
Resorcerer
Hexedit 1.8.5
Hexeditor
ResEdit (只能編 Resource fork)
等等
都只能編輯 Data fork 和 Resource fork 。而編輯 file attributes 的程式又沒有辦法對檔名之 styled text 施力。 如果 Mac 能有像 PCtools 那樣的 Hex editor ,說不定就有辦法。記得 Norton Utilities 有內附一個 Hex Editor ,不曉得這個可不可以做到。
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 悲:
<STRONG>好消息:已找到方法把 Jaguar 的中文亂碼的檔名更正,稍待,要把指令除錯及優化才公佈。
壞消息:半自動,需用家參與。
略述:把檔案及檔案夾以 Finder 拷貝之,然後借 TextEdit 幫助,把名稱轉為 unicode,從而解決亂碼的困擾。
誰有興趣及勇氣一試?</STRONG><HR></BLOCKQUOTE>
請問一下你的方法是不是類似像這樣:
亂碼檔存在硬碟上,有兩個方式可以修正那個問題:
1. 開啟 classic environment 的應用程式將檔案開啟後,再重新存一遍。之後在 OS X 底下檔名應該就會正常
2. 開啟 classic environment 的 SimpleText (不是 OS X development tool 的 SimpleText),以及 OS X 底下的 TextEdit ,接著以下列方法來修正
中文亂碼 --> SimpleText (改 Taipei 字)---> TextEdit ( 這時會變成 unicode 編碼)---> 貼回中文檔名
以上方式修正的中文檔名在 OS 9 底下反而看不到
因為只要是 OS X 或 TextEdit 碰過的中文會都變成 Unicode 。但 Unicode 在 OS 9 上無法正確顯現(除非大家都不用 OS 9 了,可能嗎? [img]images/smiles/icon_wink.gif[/img] )
改檔名的 styled text 目前應該是兩全其美的方法,這個是不是一定要寫“應用程式”才能做到?
話說回來,勇氣當然有(都敢用 OS X 了,還會怕嗎?) [img]images/smiles/icon_biggrin.gif[/img]
<STRONG>好消息:已找到方法把 Jaguar 的中文亂碼的檔名更正,稍待,要把指令除錯及優化才公佈。
壞消息:半自動,需用家參與。
略述:把檔案及檔案夾以 Finder 拷貝之,然後借 TextEdit 幫助,把名稱轉為 unicode,從而解決亂碼的困擾。
誰有興趣及勇氣一試?</STRONG><HR></BLOCKQUOTE>
請問一下你的方法是不是類似像這樣:
亂碼檔存在硬碟上,有兩個方式可以修正那個問題:
1. 開啟 classic environment 的應用程式將檔案開啟後,再重新存一遍。之後在 OS X 底下檔名應該就會正常
2. 開啟 classic environment 的 SimpleText (不是 OS X development tool 的 SimpleText),以及 OS X 底下的 TextEdit ,接著以下列方法來修正
中文亂碼 --> SimpleText (改 Taipei 字)---> TextEdit ( 這時會變成 unicode 編碼)---> 貼回中文檔名
以上方式修正的中文檔名在 OS 9 底下反而看不到
因為只要是 OS X 或 TextEdit 碰過的中文會都變成 Unicode 。但 Unicode 在 OS 9 上無法正確顯現(除非大家都不用 OS 9 了,可能嗎? [img]images/smiles/icon_wink.gif[/img] )
改檔名的 styled text 目前應該是兩全其美的方法,這個是不是一定要寫“應用程式”才能做到?
話說回來,勇氣當然有(都敢用 OS X 了,還會怕嗎?) [img]images/smiles/icon_biggrin.gif[/img]
- bryanchang
- 討論區管理員
- 文章: 7057
- 註冊時間: 04/19/2001 1:01 am
- 來自: The '60s
- 聯繫:
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 悲:
<STRONG>誰有興趣及勇氣一試?</STRONG><HR></BLOCKQUOTE>
聽來不錯,算我一份吧:bryanchang@mac.com
<STRONG>誰有興趣及勇氣一試?</STRONG><HR></BLOCKQUOTE>
聽來不錯,算我一份吧:bryanchang@mac.com
老問題:中文檔名
夜深了,踫到難題未解,先說方法吧。
用 applescript 控制 Finder 把亂碼的檔案拷貝,然後把檔案名稱的 ktxt 值寫成 plain file;在 TextEdit 中,手動選 Traditional Chinese (Mac OS) 開啓此 plain file,此時檔案名稱能正確顯示,把資料傳回 Finder,rename 拷貝。
原本打算用 droplet 處理大量檔案,但 TextEdit 選 encoding 不是 scriptable;想得頭昏,明天再續。
用 applescript 控制 Finder 把亂碼的檔案拷貝,然後把檔案名稱的 ktxt 值寫成 plain file;在 TextEdit 中,手動選 Traditional Chinese (Mac OS) 開啓此 plain file,此時檔案名稱能正確顯示,把資料傳回 Finder,rename 拷貝。
原本打算用 droplet 處理大量檔案,但 TextEdit 選 encoding 不是 scriptable;想得頭昏,明天再續。
老問題:中文檔名
在
/Developer/Applications/Extra/
有一個程式也叫 SimpleText
可以處理(貼上) big5 中文碼,
而拷貝到 Finder 時,到 Get Info 視窗上的
Name & Extension 項目上貼上後可以顯示正常
中文。我想這些動作 AppleScript 應該可以處理。
若不經由 Get Info 視窗,而是直接在 Finder 上貼上檔名。
結果反而是中文亂碼。不曉得這是 bug 還是 feature。
作業系統: OS X 10.2.2
[ 11-21-2002: 留言編輯者: macluo ]
/Developer/Applications/Extra/
有一個程式也叫 SimpleText
可以處理(貼上) big5 中文碼,
而拷貝到 Finder 時,到 Get Info 視窗上的
Name & Extension 項目上貼上後可以顯示正常
中文。我想這些動作 AppleScript 應該可以處理。
若不經由 Get Info 視窗,而是直接在 Finder 上貼上檔名。
結果反而是中文亂碼。不曉得這是 bug 還是 feature。
作業系統: OS X 10.2.2
[ 11-21-2002: 留言編輯者: macluo ]
- the real unknown
- 冰果室打手
- 文章: 2610
- 註冊時間: 04/26/2001 1:01 am
- 來自: GMT-5
- 聯繫:
老問題:中文檔名
白老大,
已電郵之,請查看。
試試以下指令,用 Script Editor 編譯之,儲存為 application。
或到我的 iDisk 下載 rTCname 及 rTCname readme.pdf
http://homepage.mac.com/cherish/FileSharing1.html
<BLOCKQUOTE><font size="1" face="XYZ">code:</font><HR><pre>
property tristeReady : false
property triste : missing value
property itemList : {}
on open theSelection
set triste to "RTC" & (do shell script "date +%s")
set tFile to (path to desktop as string) & "c" & triste
tell application "Finder" to set itemList to every item of theSelection
repeat with i in itemList
set iData to "" & contents of i & return
my writeFile(iData, tFile, true)
end repeat
set tristeReady to true
tell application "Finder" to activate
delay 1
tell application "TextEdit" to activate
end open
on run
if tristeReady = false then
say "i am not ready"
display dialog "please drag and drop the files and/or folders on me" giving up after 5
else if tristeReady = true then
tell application "TextEdit" to set tFileOpen to name of window 1
if not (tFileOpen starts with "cRTC") then
say "please select Traditional Chinese encoding when open the c R T C file"
display dialog "please select Traditional Chinese encoding when open the c R T C file" giving up after 5
else
tell application "TextEdit"
set pText to text of document 1
close window 1
quit
end tell
set mItemList to paragraphs 1 thru -2 of pText
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set nList to {}
repeat with i in mItemList
set end of nList to text item -1 of i
end repeat
set AppleScript's text item delimiters to oldTIDs
tell application "Finder" to make new folder with properties {name:triste}
set tFolder to (path to desktop as string) & triste
tell application "Finder" to open folder tFolder
repeat with i from 1 to count of itemList
tell application "Finder"
try
set cItem to (duplicate (item i of itemList) to tFolder as alias replacing yes) as alias
end try
try
set name of cItem to item i of nList
end try
end tell
end repeat
set itemList to {}
set tristeReady to false
end if
end if
end run
on writeFile(thisData, targetFile, appenData)
try
set the targetFile to the targetFile as text
set the openTargetFile to open for access file targetFile with write permission
if appenData is false then set eof of the openTargetFile to 0
write thisData to the openTargetFile starting at eof
close access the openTargetFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeFile
</pre><HR></BLOCKQUOTE>
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>可以處理(貼上) big5 中文碼,
而拷貝到 Finder 時,到 Get Info 視窗上的
Name & Extension 項目上貼上後可以顯示正常
中文。我想這些動作 AppleScript 應該可以處理。<HR></BLOCKQUOTE>
美麗的誤會。在大多數情况下,applescript 不是模擬鍵盤輸入或滑鼠的點擊。
已電郵之,請查看。
試試以下指令,用 Script Editor 編譯之,儲存為 application。
或到我的 iDisk 下載 rTCname 及 rTCname readme.pdf
http://homepage.mac.com/cherish/FileSharing1.html
<BLOCKQUOTE><font size="1" face="XYZ">code:</font><HR><pre>
property tristeReady : false
property triste : missing value
property itemList : {}
on open theSelection
set triste to "RTC" & (do shell script "date +%s")
set tFile to (path to desktop as string) & "c" & triste
tell application "Finder" to set itemList to every item of theSelection
repeat with i in itemList
set iData to "" & contents of i & return
my writeFile(iData, tFile, true)
end repeat
set tristeReady to true
tell application "Finder" to activate
delay 1
tell application "TextEdit" to activate
end open
on run
if tristeReady = false then
say "i am not ready"
display dialog "please drag and drop the files and/or folders on me" giving up after 5
else if tristeReady = true then
tell application "TextEdit" to set tFileOpen to name of window 1
if not (tFileOpen starts with "cRTC") then
say "please select Traditional Chinese encoding when open the c R T C file"
display dialog "please select Traditional Chinese encoding when open the c R T C file" giving up after 5
else
tell application "TextEdit"
set pText to text of document 1
close window 1
quit
end tell
set mItemList to paragraphs 1 thru -2 of pText
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set nList to {}
repeat with i in mItemList
set end of nList to text item -1 of i
end repeat
set AppleScript's text item delimiters to oldTIDs
tell application "Finder" to make new folder with properties {name:triste}
set tFolder to (path to desktop as string) & triste
tell application "Finder" to open folder tFolder
repeat with i from 1 to count of itemList
tell application "Finder"
try
set cItem to (duplicate (item i of itemList) to tFolder as alias replacing yes) as alias
end try
try
set name of cItem to item i of nList
end try
end tell
end repeat
set itemList to {}
set tristeReady to false
end if
end if
end run
on writeFile(thisData, targetFile, appenData)
try
set the targetFile to the targetFile as text
set the openTargetFile to open for access file targetFile with write permission
if appenData is false then set eof of the openTargetFile to 0
write thisData to the openTargetFile starting at eof
close access the openTargetFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeFile
</pre><HR></BLOCKQUOTE>
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>可以處理(貼上) big5 中文碼,
而拷貝到 Finder 時,到 Get Info 視窗上的
Name & Extension 項目上貼上後可以顯示正常
中文。我想這些動作 AppleScript 應該可以處理。<HR></BLOCKQUOTE>
美麗的誤會。在大多數情况下,applescript 不是模擬鍵盤輸入或滑鼠的點擊。
- bryanchang
- 討論區管理員
- 文章: 7057
- 註冊時間: 04/19/2001 1:01 am
- 來自: The '60s
- 聯繫:
老問題:中文檔名
非常感謝,不過到目前還未收到您的信。
我的 email 是:bryanchang@mac.com
我的 email 是:bryanchang@mac.com
- bryanchang
- 討論區管理員
- 文章: 7057
- 註冊時間: 04/19/2001 1:01 am
- 來自: The '60s
- 聯繫:
老問題:中文檔名
我剛用 Cocoa 寫了個簡單的轉換程式,也許可以做個 droplet 來直接做轉換。
- the real unknown
- 冰果室打手
- 文章: 2610
- 註冊時間: 04/26/2001 1:01 am
- 來自: GMT-5
- 聯繫:
老問題:中文檔名
我是AppleScript/Cocoa白癡,可是這些script看起來會把檔案整個拷貝一次。那檔案很大的時候...
老問題:中文檔名
白老大,
剛發現 droplet 在電郵過程中損毁,現弄了一個 rTCname.dmg,請查看或下載。
http://homepage.mac.com/cherish/FileSharing1.html
也不行的話,自行編譯上一個留言的指令也可 [img]images/smiles/icon_smile.gif[/img]
剛發現 droplet 在電郵過程中損毁,現弄了一個 rTCname.dmg,請查看或下載。
http://homepage.mac.com/cherish/FileSharing1.html
也不行的話,自行編譯上一個留言的指令也可 [img]images/smiles/icon_smile.gif[/img]
老問題:中文檔名
白老大,
今天有少許改進,只需拖放;亂碼的檔案會拷貝及轉成正確顯示的中文名稱。
最高興的是找到方法控制 TextEdit 選 encoding,所以整個流程簡化了,也較不易出錯。下一步是 recursive 的處理檔案及檔案夾。
用 cocoa 改寫,真羨慕啊。
請查看電郵,下載 RTC.dmg 或自行編譯。
http://homepage.mac.com/cherish/FileSharing1.html
<BLOCKQUOTE><font size="1" face="XYZ">code:</font><HR><pre>
on open theSelection
tell application "TextEdit" to quit
do shell script "defaults write com.apple.TextEdit PlainTextEncoding '-2147483646'"
set triste to "RTC" & (do shell script "date +%s")
set tFolder to ((path to desktop as string) & triste)
set tFile to tFolder & ":" & triste
tell application "Finder"
make new folder with properties {name:triste}
open folder tFolder
set itemList to every item of theSelection
end tell
repeat with i in itemList
set iData to "" & contents of i & return
my writeFile(iData, tFile, true)
end repeat
tell application "Finder" to activate
delay 1
tell application "TextEdit"
open (tFile as alias)
set pText to text of document 1
close window 1
quit
end tell
do shell script "defaults delete com.apple.TextEdit PlainTextEncoding"
set mItemList to paragraphs 1 thru -2 of pText
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set nList to {}
repeat with i in mItemList
set end of nList to text item -1 of i
end repeat
set AppleScript's text item delimiters to oldTIDs
repeat with i from 1 to count of itemList
tell application "Finder"
try
set cItem to (duplicate (item i of itemList) to tFolder as alias replacing yes) as alias
end try
try
set name of cItem to item i of nList
end try
end tell
end repeat
end open
on run
say "please drag and drop files on droplet R T C"
display dialog "please drag and drop files on droplet RTC" giving up after 10
end run
on writeFile(thisData, targetFile, appenData)
try
set the targetFile to the targetFile as text
set the openTargetFile to open for access file targetFile with write permission
if appenData is false then set eof of the openTargetFile to 0
write thisData to the openTargetFile starting at eof
close access the openTargetFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeFile
</pre><HR></BLOCKQUOTE>
<BLOCKQUOTE><font size="1" face="XYZ">quote
萬一出錯時,原來的檔案無礙。
CD 或 唯讀的 filesystem 的情况也適用。
當然,小弟也同意檔案很大時,Finder 會...
今天有少許改進,只需拖放;亂碼的檔案會拷貝及轉成正確顯示的中文名稱。
最高興的是找到方法控制 TextEdit 選 encoding,所以整個流程簡化了,也較不易出錯。下一步是 recursive 的處理檔案及檔案夾。
用 cocoa 改寫,真羨慕啊。
請查看電郵,下載 RTC.dmg 或自行編譯。
http://homepage.mac.com/cherish/FileSharing1.html
<BLOCKQUOTE><font size="1" face="XYZ">code:</font><HR><pre>
on open theSelection
tell application "TextEdit" to quit
do shell script "defaults write com.apple.TextEdit PlainTextEncoding '-2147483646'"
set triste to "RTC" & (do shell script "date +%s")
set tFolder to ((path to desktop as string) & triste)
set tFile to tFolder & ":" & triste
tell application "Finder"
make new folder with properties {name:triste}
open folder tFolder
set itemList to every item of theSelection
end tell
repeat with i in itemList
set iData to "" & contents of i & return
my writeFile(iData, tFile, true)
end repeat
tell application "Finder" to activate
delay 1
tell application "TextEdit"
open (tFile as alias)
set pText to text of document 1
close window 1
quit
end tell
do shell script "defaults delete com.apple.TextEdit PlainTextEncoding"
set mItemList to paragraphs 1 thru -2 of pText
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set nList to {}
repeat with i in mItemList
set end of nList to text item -1 of i
end repeat
set AppleScript's text item delimiters to oldTIDs
repeat with i from 1 to count of itemList
tell application "Finder"
try
set cItem to (duplicate (item i of itemList) to tFolder as alias replacing yes) as alias
end try
try
set name of cItem to item i of nList
end try
end tell
end repeat
end open
on run
say "please drag and drop files on droplet R T C"
display dialog "please drag and drop files on droplet RTC" giving up after 10
end run
on writeFile(thisData, targetFile, appenData)
try
set the targetFile to the targetFile as text
set the openTargetFile to open for access file targetFile with write permission
if appenData is false then set eof of the openTargetFile to 0
write thisData to the openTargetFile starting at eof
close access the openTargetFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeFile
</pre><HR></BLOCKQUOTE>
<BLOCKQUOTE><font size="1" face="XYZ">quote
編寫時的考慮:可是這些script看起來會把檔案整個拷貝一次。那檔案很大的時候...
萬一出錯時,原來的檔案無礙。
CD 或 唯讀的 filesystem 的情况也適用。
當然,小弟也同意檔案很大時,Finder 會...
- bryanchang
- 討論區管理員
- 文章: 7057
- 註冊時間: 04/19/2001 1:01 am
- 來自: The '60s
- 聯繫:
老問題:中文檔名
好啦~由於大家的祈擣上達了天聽,今早我在出門撿報紙時在路邊看到這個玩意兒:
http://homepage.mac.com/bryanchang/CorrectBIG5FilenameCM.sit
安裝方式:
下載後把檔案拷貝到 /Library/Contextual Menu Items 裡面後 Logout 再 login 就可以了。
使用步驟:
選取一個或多個有亂碼檔名的檔案,按下滑鼠右鍵後,選取 "Correct Big5 Filename" 指令即可。
請各位開始測試吧!
http://homepage.mac.com/bryanchang/CorrectBIG5FilenameCM.sit
安裝方式:
下載後把檔案拷貝到 /Library/Contextual Menu Items 裡面後 Logout 再 login 就可以了。
使用步驟:
選取一個或多個有亂碼檔名的檔案,按下滑鼠右鍵後,選取 "Correct Big5 Filename" 指令即可。
請各位開始測試吧!
老問題:中文檔名
<BLOCKQUOTE><font size="1" face="XYZ">quote:</font><HR>原始發信人 白萊恩:
<STRONG>
使用步驟:
選取一個或多個有亂碼檔名的檔案,按下滑鼠右鍵後,選取 "Correct Big5 Filename" 指令即可。
請各位開始測試吧!</STRONG><HR></BLOCKQUOTE>
I tried it on my Desktop and my icon layout was totaly shifted down about half screen. 真是奇怪.... [img]images/smiles/icon_rolleyes.gif[/img]
<STRONG>
使用步驟:
選取一個或多個有亂碼檔名的檔案,按下滑鼠右鍵後,選取 "Correct Big5 Filename" 指令即可。
請各位開始測試吧!</STRONG><HR></BLOCKQUOTE>
I tried it on my Desktop and my icon layout was totaly shifted down about half screen. 真是奇怪.... [img]images/smiles/icon_rolleyes.gif[/img]