テスト投稿ですよ


ためしに記事を投稿してみました。

AppleScriptリストの掲載テスト


スクリプト名:ファイルの安全な書き出し
set aFPath to choose file name
set aData to ABC
set fRes to write_to_file_Safely(aData, aFPath) of me

安全なファイルの書き出し
on write_to_file_Safely(this_data, target_file)
set finalPath to target_file

テンポラリフォルダに一度書き出して、ターゲットのパスに移動
set tmpFol to path to temporary items from system domain
set tmpName to do shell script date +%Y%m%d%H%M%S
set tmpPath to (tmpFol as string) & tmpName

テンポラリのパスにファイル書き出し
try
set the target_file to the tmpPath as text
set the open_target_file to open for access file target_file with write permission
set eof of the open_target_file to 0 つねにoverwrite mode
write this_data to the open_target_file starting at eof
close access the open_target_file

on error error_message
try
close access file target_file
end try
return error_message
end try

ファイルの移動を行う
set tFilePOSIX to quoted form of POSIX path of target_file
set fPathPOSIX to quoted form of POSIX path of finalPath
set sText to mv & tFilePOSIX & & fPathPOSIX
try
do shell script sText
on error error_message
return error_message
end try

return true

end write_to_file_Safely

▼新規書類に ▼カーソル位置に ▼ドキュメント末尾に

Hello world!


Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

フォロー

Get every new post delivered to your Inbox.