Finder

[Finder] updateコマンド

【スクリプトエディタで開く】 |

001
002#デスクトップフォルダを更新
003set aliasDesktopDirPath to (path to desktop folder from user domain) as alias
004tell application "Finder"
005   update aliasDesktopDirPath
006end tell
007
008#ダウンロードフォルダ更新
009set aliasDownloadsDirPath to (path to downloads folder from user domain) as alias
010tell application "Finder"
011   update aliasDownloadsDirPath
012end tell
013
014#使い方
015set aliasDesktopDirPath to (path to desktop folder from user domain) as alias
016tell application "Finder"
017   #フォルダを作って
018   make new folder at folder aliasDesktopDirPath with properties {|name|:"名称未設定フォルダ"}
019   set aliasDistDir to (folder "名称未設定フォルダ" of folder aliasDesktopDirPath) as alias
020   #ラベルを指定した後で
021   set label index of aliasDistDir to 1
022   #その結果を反映させる
023   update aliasDesktopDirPath
024end tell

| | コメント (0)

拡張子の変更

拡張子変更.scpt

AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005use AppleScript version "2.8"
006use scripting additions
007
008#拡張子をこれに変える
009set strChgExtension to ("jpg") as text
010#拡張子のチェックをする拡張子
011set listChkExtension to {"jpeg", "JPG", "JPEG"} as list
012#ダイアログ ファイル選択
013set strName to (name of current application) as text
014if strName is "osascript" then
015  tell application "SystemUIServer" to activate
016else
017  tell current application to activate
018end if
019tell application "Finder"
020  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
021end tell
022set listUTI to {"public.image"}
023set strMes to ("ファイルを選んでください") as text
024set strPrompt to ("ファイルを選んでください") as text
025try
026  tell application "SystemUIServer"
027    activate
028    set listAliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI with invisibles, multiple selections allowed and showing package contents) as list
029  end tell
030on error
031  log "エラーしました"
032  return "エラーしました"
033end try
034if listAliasFilePath is {} then
035  return "選んでください"
036end if
037#選択したファイルだけ繰り返し
038repeat with itemFilePath in listAliasFilePath
039  #エイリアス形式を確定
040  set aliasFilePath to itemFilePath as alias
041  #Finder
042  tell application "Finder"
043    tell file aliasFilePath
044      #現時点の拡張子
045      set strExtension to name extension as text
046    end tell
047  end tell
048  #対象リストに含まれている場合は
049  if listChkExtension contains strExtension then
050    tell application "Finder"
051      #拡張子を指定の形式に変更
052      set name extension of file aliasFilePath to strChgExtension
053    end tell
054  end if
055end repeat
056
057
AppleScriptで生成しました

|

[Finder]デスクトップウィジェット(案外使える 良いかも)

恐る々使い始めた デスクトップウィジェットだけど
ショートカット(Shortcuts)は良い♪とても便利
クリック率の高いのは
Music.appの次の曲へスキップ+再生済みカウント入れる

NO1は日付テキストのコピー
デスクトップをちょんとクリックすると
クリップボードに日付テキストが入る これは便利

ポイントは
メインモニタ上ではなく サブモニタ上で展開する
そうすると、意外にジャマにならない
202502130507281_693x225

|

[Finder] AppleScript で Finder 項目を選択する(新規FInder Windowを作って指定ファイルを選択)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* com.cocolog-nifty.quicktimer.icefloe
004*)
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "AppKit"
009use scripting additions
010
011property refMe : a reference to current application
012
013set strFilePaht to ("/Library/Documentation/License.lpdf") as text
014set aliasFilePath to (POSIX file strFilePaht) as alias
015
016
017tell application "Finder"
018  set strFileName to name of aliasFilePath
019  set aliasContainerDirPath to (container of aliasFilePath) as alias
020end tell
021
022##ファイル名で選択する
023tell application "Finder"
024  set objFinerWindow to make new Finder window to folder aliasContainerDirPath
025  tell front Finder window
026    select item strFileName
027  end tell
028end tell
029
030##ファイルパスでで選択する場合
031tell application "Finder"
032  set objFinerWindow to make new Finder window to folder aliasContainerDirPath
033  select item aliasFilePath
034end tell
035
036
037##選択項目=ファイル名指定で新規WINDOW
038tell application "Finder"
039  make new Finder window to folder aliasContainerDirPath with properties {|select|:strFileName}
040end tell
041
042
043########################
044#OBJC方式で選択
045set strFilePath to (POSIX path of aliasFilePath) as text
046set strContainerDirPath to (POSIX path of aliasContainerDirPath) as text
047
048#ファイルパス
049set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
050set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051
052#DIRパス
053set ocidDirPathStr to refMe's NSString's stringWithString:(strContainerDirPath)
054set ocidDirPath to ocidDirPathStr's stringByStandardizingPath()
055
056#選択
057set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
058set boolDone to appSharedWorkspace's selectFile:(ocidFilePath) inFileViewerRootedAtPath:(ocidDirPath)
AppleScriptで生成しました

|

Dock再起動


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010tell application id "com.apple.dock" to quit
011delay 2
012tell application id "com.apple.dock"to launch
013delay 1
014tell application id "com.apple.dock" to activate
AppleScriptで生成しました

OBJC
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015
016
017set ocidAppListArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:("com.apple.dock")
018set appRunningApp to ocidAppListArray's firstObject()
019#終了を試みる
020set boolDone to appRunningApp's terminate()
021if boolDone is false then
022  set boolDone to appRunningApp's forceTerminate()
023end if
024if boolDone is false then
025  return "Finderの終了し失敗しました"
026end if
027delay 3
028#起動
029set appWorkspace to refMe's NSWorkspace's sharedWorkspace()
030set ocidAppPathURL to appWorkspace's URLForApplicationWithBundleIdentifier:("com.apple.dock")
031set appConf to refMe's NSWorkspaceOpenConfiguration
032set ocidConf to appConf's configuration()
033appWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidConf) completionHandler:(missing value)
034
AppleScriptで生成しました

zsh
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010
011set strCommandText to ("/usr/bin/killall \"Dock\"")
012log "\r" & strCommandText & "\r"
013set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
014try
015  set strResponse to (do shell script strCommandText) as text
016on error
017  return "zshエラーしました"
018end try
019log strResponse
020return strResponse
AppleScriptで生成しました

|

SystemUIServer再起動(Menu barほか)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010
011
012tell application id "com.apple.systemuiserver" to quit
013delay 2
014tell application id "com.apple.systemuiserver"to launch
015delay 1
016tell application id "com.apple.systemuiserver" to activate
AppleScriptで生成しました

OBJC
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014set ocidAppListArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:("com.apple.systemuiserver")
015set appRunningApp to ocidAppListArray's firstObject()
016#終了を試みる
017set boolDone to appRunningApp's terminate()
018if boolDone is false then
019  set boolDone to appRunningApp's forceTerminate()
020end if
021if boolDone is false then
022  return "Finderの終了し失敗しました"
023end if
024delay 3
025#起動
026set appWorkspace to refMe's NSWorkspace's sharedWorkspace()
027set ocidAppPathURL to appWorkspace's URLForApplicationWithBundleIdentifier:("com.apple.systemuiserver")
028set appConf to refMe's NSWorkspaceOpenConfiguration
029set ocidConf to appConf's configuration()
030appWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidConf) completionHandler:(missing value)
031
AppleScriptで生成しました

BASH
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010
011set strCommandText to ("/usr/bin/killall \"SystemUIServer\"")
012log "\r" & strCommandText & "\r"
013set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
014try
015  set strResponse to (do shell script strCommandText) as text
016on error
017  return "zshエラーしました"
018end try
019log strResponse
020return strResponse
AppleScriptで生成しました

launchctl
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010set strCommandText to ("/bin/launchctl unload \"/System/Library/LaunchAgents/com.apple.SystemUIServer.plist\"")
011log "\r" & strCommandText & "\r"
012set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
013try
014  set strResponse to (do shell script strCommandText) as text
015on error
016  return "unloadエラーしました"
017end try
018log strResponse
019
020delay 1
021
022set strCommandText to ("/bin/launchctl load \"/System/Library/LaunchAgents/com.apple.SystemUIServer.plist\"")
023log "\r" & strCommandText & "\r"
024set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
025try
026  set strResponse to (do shell script strCommandText) as text
027on error
028  return "loadエラーしました"
029end try
030log strResponse
031
032set strCommandText to ("/usr/bin/open -b \"com.apple.SystemUIServer\"")
033log "\r" & strCommandText & "\r"
034set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
035try
036  set strResponse to (do shell script strCommandText) as text
037on error
038  return "openエラーしました"
039end try
AppleScriptで生成しました

|

Finder再起動


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010tell application "Finder" to quit
011delay 2
012tell application "Finder" to launch
013delay 1
014tell application "Finder" to activate
AppleScriptで生成しました

OBJC
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014set ocidAppListArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:("com.apple.finder")
015set appRunningApp to ocidAppListArray's firstObject()
016#終了を試みる
017set boolDone to appRunningApp's terminate()
018if boolDone is false then
019  set boolDone to appRunningApp's forceTerminate()
020end if
021if boolDone is false then
022  return "Finderの終了し失敗しました"
023end if
024delay 3
025#起動
026set appWorkspace to refMe's NSWorkspace's sharedWorkspace()
027# 非推奨になった
028#appWorkspace's launchApplication:("Finder")
029set ocidAppPathURL to appWorkspace's URLForApplicationWithBundleIdentifier:("com.apple.finder")
030set appConf to refMe's NSWorkspaceOpenConfiguration
031set ocidConf to appConf's configuration()
032(ocidConf's setActivates:(refMe's NSNumber's numberWithBool:true))
033(ocidConf's setHides:(refMe's NSNumber's numberWithBool:false))
034appWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidConf) completionHandler:(missing value)
AppleScriptで生成しました

zsh
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010set strCommandText to ("/usr/bin/killall \"Finder\"")
011log "\r" & strCommandText & "\r"
012set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
013try
014  set strResponse to (do shell script strCommandText) as text
015on error
016  return "zshエラーしました"
017end try
018log strResponse
019return strResponse
AppleScriptで生成しました

launchctl
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005#
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use scripting additions
009
010set strCommandText to ("/bin/launchctl unload \"/System/Library/LaunchAgents/com.apple.Finder.plist\"")
011log "\r" & strCommandText & "\r"
012set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
013try
014  set strResponse to (do shell script strCommandText) as text
015on error
016  return "unloadエラーしました"
017end try
018log strResponse
019
020delay 1
021
022set strCommandText to ("/bin/launchctl load \"/System/Library/LaunchAgents/com.apple.Finder.plist\"")
023log "\r" & strCommandText & "\r"
024set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
025try
026  set strResponse to (do shell script strCommandText) as text
027on error
028  return "loadエラーしました"
029end try
030log strResponse
031
032set strCommandText to ("/usr/bin/open -b \"com.apple.Finder\"")
033log "\r" & strCommandText & "\r"
034set strExecCommand to ("/bin/zsh -c '" & strCommandText & "'") as text
035try
036  set strResponse to (do shell script strCommandText) as text
037on error
038  return "openエラーしました"
039end try
AppleScriptで生成しました

|

[Finder]エイリアスの参照元の取得

シンボリックリンクは取得できない
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006
007#シンボリックリンク
008set strFilePath to ("/Library/Fonts/Arial Unicode.ttf") as text
009
010tell application "Finder"
011  try
012    set aliasFilePath to (POSIX file strFilePath) as alias
013    set aliasResolvedPath to (original item of aliasFilePath) as alias
014  on error
015    log "参照先がすでに削除済かシンボリックリンクです"
016  end try
017end tell
018
019#参照先のないシンボリックリンク
020set strFilePath to ("/.VolumeIcon.icns") as text
021
022tell application "Finder"
023  try
024    set aliasFilePath to (POSIX file strFilePath) as alias
025    set aliasResolvedPath to (original item of aliasFilePath) as alias
026  on error
027    log "参照先がすでに削除済かシンボリックリンクです"
028  end try
029end tell
030
031
032
033set strFilePath to ("/Users/some/Desktop/someエイリアス") as text
034
035tell application "Finder"
036  try
037    set aliasFilePath to (POSIX file strFilePath) as alias
038    set aliasResolvedPath to (original item of aliasFilePath) as alias
039  on error
040    display alert "参照先がすでに削除済かシンボリックリンクです"
041  end try
042end tell
AppleScriptで生成しました

|

選択ファイルの拡張子を変更する


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# com.cocolog-nifty.quicktimer.icefloe
004#
005#  同名ファイルに対応
006#
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use scripting additions
010
011
012
013#ファイルなりフォルダなりを選択する
014tell application "Finder"
015  activate
016  set listAliasPath to selection
017end tell
018#ダイアログ
019set strName to (name of current application) as text
020if strName is "osascript" then
021  tell application "Finder" to activate
022else
023  tell current application to activate
024end if
025set aliasIconPath to (POSIX file "/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns") as alias
026tell application "Finder"
027  set strDefaultAnswer to (the clipboard as text) as text
028end tell
029
030try
031  set recordResponse to (display dialog "拡張子を入力してください\n『.』カンマ不要" with title "入力してください" default answer strDefaultAnswer buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 30 without hidden answer)
032on error
033  log "エラーしました"
034  return "エラーしました"
035end try
036if true is equal to (gave up of recordResponse) then
037  return "時間切れですやりなおしてください"
038end if
039if "OK" is equal to (button returned of recordResponse) then
040  set strResponse to (text returned of recordResponse) as text
041else
042  log "キャンセルしました"
043  return "キャンセルしました"
044end if
045##改行とタブを削除しておく
046set strDistExtension to doReplace(strResponse, "\n", "")
047set strDistExtension to doReplace(strDistExtension, "\t", "")
048set strDistExtension to doReplace(strDistExtension, " ", "")
049#処理開始
050tell application "Finder"
051  
052  repeat with itemAliasPath in listAliasPath
053    #エイリアスで確定
054    set aliasPath to itemAliasPath as alias
055    #プロパティのレコードを取得して
056    set recordProperties to properties of aliasPath
057    #クラスを取得
058    set classPath to class of recordProperties
059    ##フォルダの場合
060    if classPath is folder then
061      ##フォルダの場合は処理しない
062    else
063      #フォルダでないならファイルだから
064      #元のファイル名
065      set strOrgFileName to name of aliasPath as text
066      #カンマでリストにして
067      set strDelim to AppleScript's text item delimiters
068      set AppleScript's text item delimiters to "."
069      set listFileName to every text item of strOrgFileName
070      set AppleScript's text item delimiters to strDelim
071      set numCntList to (count of listFileName) as integer
072      if numCntList = 1 then
073        set boolNoExtension to true as boolean
074        #拡張子無しファイル
075        set strBaseFileName to (listFileName) as list
076        #移動時のファイル名
077        set strSetFileName to (strBaseFileName & "." & strDistExtension) as text
078      else
079        set boolNoExtension to false as boolean
080        #拡張子を取得して
081        set strExtension to (last item of listFileName) as text
082        #最後の項目を削除
083        set listBaseFileName to (items 1 thru -2 of listFileName) as list
084        #残りの項目をカンマで繋いでベースファイル名      
085        #ファイル名リストの数を数える
086        set numCntList to (count of listBaseFileName) as integer
087        #リストの結合
088        repeat with itemNo from 1 to (numCntList) by 1
089          set itemBaseFileName to (item itemNo of listBaseFileName) as text
090          if itemNo = 1 then
091            set strBaseFileName to (itemBaseFileName) as text
092          else
093            set strBaseFileName to (strBaseFileName & "." & itemBaseFileName) as text
094          end if
095        end repeat
096        #移動時のファイル名
097        set strSetFileName to (strBaseFileName & "." & strDistExtension) as text
098      end if
099      #上位の親フォルダ
100      set aliasContainerDirPath to (container of itemAliasPath) as alias
101      #同名フォルダの有無チェック
102      set booFileChk to (exists of (file strSetFileName of folder aliasContainerDirPath)) as boolean
103      
104      #無ければ
105      if booFileChk is false then
106        #変更して
107        tell itemAliasPath
108          set name to strSetFileName
109        end tell
110      else if booFileChk is true then
111        #最大100まで同名フォルダ処理を行う
112        #同名ファイルがあった場合のカウンタ
113        set numCntNo to 1 as integer
114        set boolDoneChange to false as boolean
115        repeat while boolDoneChange is false
116          #同名がある場合は数字を付与していく
117          set strSetFileName to (strBaseFileName & " " & numCntNo & "." & strDistExtension) as text
118          log strSetFileName
119          #同名フォルダの有無チェック
120          set booFileChk to (exists of (file strSetFileName of folder aliasContainerDirPath)) as boolean
121          log booFileChk
122          #無ければ
123          if booFileChk is false then
124            #変更して
125            tell itemAliasPath
126              set name to strSetFileName
127            end tell
128            #リピートを抜ける
129            set boolDoneChange to true as boolean
130          else
131            #カウントアップ
132            set numCntNo to numCntNo + 1 as integer
133          end if
134          
135        end repeat
136      end if
137      
138      
139    end if
140  end repeat
141end tell
142
143###
144#置換
145to doReplace(argOrignalText, argSearchText, argReplaceText)
146  set strDelim to AppleScript's text item delimiters
147  set AppleScript's text item delimiters to argSearchText
148  set listDelim to every text item of argOrignalText
149  set AppleScript's text item delimiters to argReplaceText
150  set strReturn to listDelim as text
151  set AppleScript's text item delimiters to strDelim
152  return strReturn
153end doReplace
AppleScriptで生成しました

|

[Finder]ゴミ箱へ入れる


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005# com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011
012property refMe : a reference to current application
013
014
015##############################
016#第一階層のみ収集
017set strDirPath to ("~/Pictures/ScreenCapture/SmallExport") as text
018set ocidDirPathStr to refMe's NSString's stringWithString:(strDirPath)
019set ocidDirPath to ocidDirPathStr's stringByStandardizingPath()
020set ocidDirPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDirPath) isDirectory:(true)
021set aliasDirPath to (ocidDirPathURL's absoluteURL()) as alias
022
023tell application "Finder"
024  set listAliasFilePath to (every item of aliasDirPath) as list
025end tell
026repeat with itemAliasFilePath in listAliasFilePath
027  tell application "Finder"
028    try
029      ##ゴミ箱へ
030      move itemAliasFilePath to the trash
031    end try
032  end tell
033end repeat
034
035
036##############################
037#第一階層のみ収集
038set strDirPath to ("~/Pictures/ScreenCapture/AutomatorExport") as text
039set ocidDirPathStr to refMe's NSString's stringWithString:(strDirPath)
040set ocidDirPath to ocidDirPathStr's stringByStandardizingPath()
041set ocidDirPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDirPath) isDirectory:(true)
042set aliasDirPath to (ocidDirPathURL's absoluteURL()) as alias
043
044tell application "Finder"
045  set listAliasFilePath to (every item of aliasDirPath) as list
046end tell
047repeat with itemAliasFilePath in listAliasFilePath
048  tell application "Finder"
049    try
050      ##ゴミ箱へ
051      move itemAliasFilePath to the trash
052    end try
053  end tell
054end repeat
055
056
057
AppleScriptで生成しました

|

より以前の記事一覧

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat 2024 Acrobat AddOn Acrobat Annotation Acrobat AppleScript Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat GentechAI Acrobat JS Acrobat JS Word Search Acrobat Maintenance Acrobat Manifest Acrobat Menu Acrobat Merge Acrobat Open Acrobat PDFPage Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Print Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat Registered Products Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat URL List Mac Acrobat URL List Windows Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin ConfigCode Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin NetWork Admin Permission Admin Pkg Admin Power Management Admin Printer Admin Printer Basic Admin Printer Custompapers Admin SetUp Admin SMB Admin softwareupdate Admin Support Admin System Information Admin TCC Admin Tools Admin Umask Admin Users Admin Volumes Admin XProtect Adobe Adobe AUSST Adobe Bridge Adobe Documents Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager Adobe Sap Code AppKit Apple AppleScript AppleScript Duplicate AppleScript entire contents AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Video Applications AppStore Archive Archive Keka Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome Chromedriver CIImage CityCode CloudStorage Color Color NSColor Color NSColorList com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Desktop Position Device Diff Disk do shell script Dock Dock Launchpad DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData exiftool ffmpeg File File Name Finder Finder Window Firefox Folder FolderAction Font List FontCollections Fonts Fonts Asset_Font Fonts ATS Fonts Emoji Fonts Maintenance Fonts Morisawa Fonts Python Fonts Variable Foxit GIF github Guide HTML Icon Icon Assets.car Illustrator Image Events ImageOptim Input Dictionary iPhone iWork Javascript Jedit Ω Json Label Language Link locationd lsappinfo m3u8 Mail Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Microsoft Office Link Microsoft OneDrive Microsoft Teams Mouse Music Node Notes NSArray NSArray Sort NSAttributedString NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSGraphicsContext Crop NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSet NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSUbiquitous NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth PDF PDF Image2PDF PDF MakePDF PDF nUP PDF Pymupdf PDF Pypdf PDFContext PDFDisplayBox PDFImageRep PDFKit PDFKit Annotation PDFKit AnnotationWidget PDFKit DocumentPermissions PDFKit OCR PDFKit Outline PDFKit Start PDFPage PDFPage Rotation PDFView perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript PowerShell prefPane Preview Python Python eyed3 Python pip QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver Script Editor Script Menu SF Symbols character id SF Symbols Entity Shortcuts Shortcuts Events sips Skype Slack Sound Spotlight sqlite StandardAdditions StationSearch Subtitles LRC Subtitles SRT Subtitles VTT Swift swiftDialog System Events System Settings TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom Weather webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML LSSharedFileList sfl2 XML LSSharedFileList sfl3 XML objectsForXQuery XML OPML XML Plist XML Plist System Events XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube Zero Padding zoom