以下は、ファイルの名前を変更する私のコードです。"_"
コードは基本的に特殊文字をチェックし、 (アンダースコア)に置き換えます。
コード
set thefile to choose file
set Filename to my replace_chars(thefile, " ", " ")
set Filename to my replace_chars(thefile, " ", " ")
set Filename to my replace_chars(thefile, " ", "_")
set Filename to my replace_chars(thefile, ",", "_")
set Filename to my replace_chars(thefile, "!", "_")
set Filename to my replace_chars(thefile, "~", "_")
set Filename to my replace_chars(thefile, "*", "_")
set Filename to my replace_chars(thefile, "/", "_")
set Filename to my replace_chars(thefile, ":", "_")
set Filename to my replace_chars(thefile, "(", "_")
set Filename to my replace_chars(thefile, ")", "_")
set Filename to my replace_chars(thefile, "___", "_")
set Filename to my replace_chars(thefile, "__", "_")
tell application "Finder"
set the name of file thefile to "Testing.png"
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
投げ"Cant get every text item of alias"
ます アドバイスお願いします。