• ベストアンサー

AppleScriptで

shungaiの回答

  • shungai
  • ベストアンサー率47% (9/19)
回答No.2

おはようございます。 旧OS時代の古いApple Scriptでも問題ないようです。 ●「set i to name of item index j of k」が、 tell application "Finder" ~ end tell の外にある。 ●ディレクトリkがalias 型ではない。 というところでしょうか?

関連するQ&A

  • AppleScriptで

    AppleScriptで jとgはtext変数、 iはinteger変数なんですが、 gのi単語目をjのi単語目に書き換えたいのですが set word i of g to word i of j で行うとエラーになります。 どうすれbくぁいいのでしょうか。

    • 締切済み
    • Mac
  • AppleScriptで

    アピアランスでset picture file of monitor 1 to file iを実行するとエラーになります。(iにはjpgファイルの参照が指定されています)どうしてでしょう。

    • 締切済み
    • Mac
  • AppleScript で、文字を除外して読み込み

    repeat with theItem in theItems set noteName to title of item 1 of theItem set convName to noteName set title of item 1 of theItem to "Copy of " & convName end repeat 初心者で、色々と勉強中の者です。 有るスクリプトで、ファイルを触り(itm 1)  その元のタイトル(title) から、特定の文字群(例えば A や B )を省いた文字列を取得し(convName) 複製されたファイル(theItem)に対して Copy of を頭につけつつ、適用したい、 という事をやりたいのですが、これの3行目をどう書いたらよいか行き詰まっています。 例としては、 ※もとのファイル(A 0000 B.note)を、(Copy of 0000.note)にしたい という内容になります。 ちなみに、複製などその他のことは上手く行っており、Copy of を貼り付けるのも問題ないのですが、元のファイルネームから特定の文字列を除外して読み込む事だけが出来ておりません。 ご教授宜しくお願いいたします。  

  • AppleScript 添削希望

    以下のスクリプトを1回実行するとデスクトップにフォルダ「t01」ができるのですが、 2回目以降「t02」とはならず、「test」のままで止まってしまいます。 OS 10.5.8 です。どこか間違ってるのでしょうか。 tell application "Finder" duplicate folder "test" of folder "_test" of desktop to desktop with replacing try set name of folder "test" of desktop to "t01" on error try set name of folder "test" of desktop to "t02" on error try set name of folder "test" of desktop to "t03" end try end try end try end tell

    • ベストアンサー
    • Mac
  • AppleScriptファイルの読み書きについて

    Applescriptを始めたばかりの初心者です。 テキストファイルを読み込んで、検索置換を行うスクリプトを作成してます。 検索置換まではなんとかできたのですが、ファイルを同じ場所に同じ名前で上書きしたいのですが、うまくいきません。見よう見まねで作成しているので、エラーがでても対処できませんでした。 どうかアドバイスをお願いします。 set thefile to "■■HD:0000:0000.txt"--いつも同じファイルを読み込む try set fn to open for access file thefile with write permission set mystr to read fn -- 全ての内容を得る end try display dialog mystr--内容の確認 set mystr to my replaceAll(mystr, "▼", return) display dialog mystr--内容の確認 write mystr to fn close access fn on replaceAll(motoStr, findStr, repStr) set OriginalDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {findStr} set motoStr to text items of motoStr set AppleScript's text item delimiters to {repStr} set motoStr to motoStr as string set AppleScript's text item delimiters to OriginalDelimiters return motoStr end replaceAll

  • AppleScriptでpathを取得

    クリックしたファイルの絶対パスをクリップボードに保存する AppleScript(以下に記載)があるのですが、これでは クリップボードの中身が '/Users/ABC/Desktop/tmp1.jpg' '/Users/ABC/Desktop/tmp2.jpg' となります。 クオーテーション「 ' 」なしで、クリップボードに保存したいのですが どのようにすれば良いのでしょうか。 rest of characters of などを使ってどうにか組もうとしたのですが 初心者にはできませんでした。 どなたか、よろしくお願いします。 tell application "Finder" set theItems to "__OBJ_PATH__" set theResult to "" set old_delims to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" set max to count of (every text item of theItems) repeat with num from 1 to max set theResult to theResult & quoted form of (text item num of theItems) if max > 1 and num < max then set theResult to "theResult" & " " end if end repeat set AppleScript's text item delimiters to old_delims set the clipboard to theResult end tell

  • AppleScriptで教えて欲しいです。

    現在、clipboardと同じ名前のフォルダー1つ(例:ABC123)のみ処理する。 →これを、clipboardの名前を含むフォルダー1つ(例:ABC123.4)のみ処理する。 に変更したいです。 ちなみにclipboardの名前を含むフォルダーは、1つしか存在しません。 申し訳ありませんが、実際の業務で使用している下記のスクリプト(無駄な部分も多少あるかと思いますが)を出来る限り変更を加えず、可能でしょうか? 無理であれば、大幅変更も可能ですので、ご教授の程、宜しくお願い致します。 global Num global fp set Num to the clipboard tell application "Finder" my shikyuseihan2data() --支給製版2課データ try duplicate fp to folder "data" of disk "HD" move fp to folder "jus:5)製版行き: 2課使用済" end try end tell --アクセス権 tell application "Terminal" activate do script with command "chmod -R 775 /Volumes/HD/data" quit end tell --支給製版2課のデータ on shikyuseihan2data() tell application "Finder" set x to name of every disk if "jus" is in x then else mount volume "afp://10.1.30.10/jus/" end if try set fp to "jus:5)製版行き:" & Num & ":" as text set fp to fp as alias end try end tell end shikyuseihan2data

    • ベストアンサー
    • Mac
  • AppleScript、ファイルの移動について

    初心者です、以下の文で、デスクトップにある test.txt というファイルをアプリケーションフォルダーにある test というフォルダーに移動させたいのですが、エラーが出ます。 ------------------------------ tell application "Finder" set tgtFile to file "test.txt" of desktop move tgFile to folder "test" of applications folder with replacing end tell ------------------------------ エラー文 error "folder \"test\" of applications folder を取り出すことはできません。" number -1728 from «class cfol» "test" of At Ease applications folder ------------------------------ しっかりアプリケーションフォルダーにtestというファイルはあります。 改善法を教えてください<(_ _)>

    • ベストアンサー
    • Mac
  • applescriptでのファイルコピー

    macmini server (SnowLeopard:OSX10.6) 上記機種を使用。 macの知識がなく、最近applescriptという機能を知りました。 使い方が全くわからない状態でしたが、 今回、NAS(マウント済み)にあるフォルダAの中のファイルBを macのServer HDの中にあるフォルダCへコピーする作業を 自動化させたいと思い、ファイルコピーの方法について調べていたところ、 とある質問サイトで下記のコードを見つけ、入力項目を埋めて実行しました。 が、「必要なボリュームがマウントされていません」とエラーがでました。 既にマウントしているのは確認しています。 恐らくボリューム名かファイルパスの入れ方が違うのかなと思い、 いろいろと試してみましたが、出来ませんでした。 ここでいうボリューム名とファイルパスとフォルダパスは どのような入れ方をすればよいのでしょうか? もしくは、他の原因であれば、その解決策を教えて頂けると 助かります。 すみませんが宜しくお願い致します。 ------ ペーストするコード (以下最後まで) -------------------- ----【入力項目】------------ set FromVolumName to "ボリューム名を入れる" ---(↑説明)コピー元となるファイルのあるボリューム名 set ToVolumName to "ボリューム名を入れる" ---(↑説明)コピー先となるフォルダのあるボリューム名 set FromCopyFile to "ファイルパスを入れる" ---(↑説明)コピー元となるファイルのパス set ToCopyFolder to "フォルダパスを入れる" ---(↑説明)コピー先となるフォルダのパス set CP_opt to "-f" ---(↑説明)cpコマンドのオプション ------------------------- tell application "Finder" set {MyMsg, MyIcn} to {"完了!", 1} if (exists disk FromVolumName) and (exists disk ToVolumName) then try do shell script "cp " & CP_opt & " " & quoted form of POSIX path of FromCopyFile & " " & quoted form of POSIX path of ToCopyFolder on error set {MyMsg, MyIcn} to {"なんらかのエラーです!", 0} end try else set {MyMsg, MyIcn} to {"必要なボリュームがマウントされていません!", 0} end if activate display dialog MyMsg buttons {"終了"} default button 1 with icon MyIcn end tell

    • ベストアンサー
    • Mac
  • applescript スクリプトエディタとアプリケーションで実行結果が異なる

    クリップボードの文字列を検索置換しようとしています。 \\hoge\hogehoge→/Volumes/hogehogeのように。 ソースは下記なんですが、スクリプトエディタ上で実行すると 期待された結果が返ってくるのですが、アプリケーションとして 保存し、デスクトップからアプリケーションを実行すると 置換二つ目が処理されず、なぜか置換一つ目しか処理されません。 どのようにしたらよいでしょうか。 set theText to get the clipboard set backslash to ASCII character 128 set searchWd to backslash if (offset in theText of searchWd) = 0 then else set theText to my replaceTxt(theText, backslash, "/") --置換一つ目 set theText to my replaceTxt(theText, "//hoge", "/Volumes") --置換二つ目 display dialog theText end if on replaceTxt(myText, searchTxt, replaceTxt) set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to searchTxt set myText to every text item of myText set AppleScript's text item delimiters to replaceTxt set myText to myText as string set AppleScript's text item delimiters to oldDel return myText end replaceTxt