CloudStorage

[CloudStorage]CloudStorageのローカルディレクトリを開く 少し修正


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions
property refMe : a reference to current application

###設定項目 ディレクトリ名の接頭語
property strStartWithName : "Box"


##ファイルマネージャー初期化
set appFileManager to refMe's NSFileManager's defaultManager()
##CloudStorageのURL
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidCloudStorageURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:"CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
set ocidPathArray to item 1 of listPathUrlArray
####################################
##ディレクトリ名を取得
####################################
set listDirName to {"iCloud Drive", "Air Drop"} as list

##AdobeCC利用中かチェックする
set ocidHomeDirPathURL to appFileManager's homeDirectoryForCurrentUser()
set ocidChkDirPathURL to ocidHomeDirPathURL's URLByAppendingPathComponent:("Creative Cloud Files") isDirectory:true
set ocidChkDirPath to ocidChkDirPathURL's |path|()
set boolExistChk to appFileManager's fileExistsAtPath:(ocidChkDirPath) isDirectory:(true)
if boolExistChk is true then
  set end of listDirName to "Creative Cloud Files"
end if
####カウンター初期化
set numIndex to 1 as integer
##CloudStorageにあるディレクトリをリストに入れる
repeat with itemPathArray in ocidPathArray
  set ocidDirName to itemPathArray's lastPathComponent()
  set strDirName to ocidDirName as text
  ###デフォルトをBoxにしたい場合
  if strDirName starts with strStartWithName then
    if boolExistChk is true then
      set numDefaultItems to numIndex + 3 as integer
    else
      set numDefaultItems to numIndex + 2 as integer
    end if
  end if
  set end of listDirName to strDirName
  set numIndex to numIndex + 1 as integer
end repeat

####################################
##ダイアログ
####################################

###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
try
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item numDefaultItems of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  else
    ####スクリプトエディタから実行したら
    tell current application
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item numDefaultItems of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  end if
on error
  log "エラーしました"
return "エラーしました"
  error "エラーしました" number -200
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
  error "キャンセルしました" number -200
end if
####ワークスペース初期化
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
####ダイアログで選択した数だけ繰り返し
repeat with itemResponse in listResponse
  set strResponse to itemResponse as text
  ##別処理のための分岐
  if strResponse is "iCloud Drive" then
    ###URLにしてからパスに戻して
    set ocidiCloudFilePathURL to (ocidUserLibraryPathURL's URLByAppendingPathComponent:("Mobile Documents") isDirectory:true)
    set ocidiCloudFilePath to ocidiCloudFilePathURL's |path|()
    ###開く
(appSharedWorkspace's selectFile:(missing value) inFileViewerRootedAtPath:(ocidiCloudFilePath))
  else if strResponse is "Creative Cloud Files" then
    ###開く
(appSharedWorkspace's selectFile:(ocidChkDirPath) inFileViewerRootedAtPath:(ocidChkDirPath))
  else if strResponse is "Air Drop" then
    set strBundleID to "com.apple.finder.Open-AirDrop" as text
    ##NSBundleで取得出来なければNSWorkspaceで取得
    set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
    if ocidAppBundle ≠ (missing value) then
      set ocidAppPathURL to ocidAppBundle's bundleURL()
    else if ocidAppBundle = (missing value) then
      set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
    end if
    ###開く
    set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
(ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true))
(appSharedWorkspace's openApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value))
  else
    ###URLにしてからパスに戻して
    set ocidCloudStorageFilePathURL to (ocidCloudStorageURL's URLByAppendingPathComponent:(strResponse))
    set ocidCloudStorageFilePath to ocidCloudStorageFilePathURL's |path|()
    ###開く
(appSharedWorkspace's selectFile:(missing value) inFileViewerRootedAtPath:(ocidCloudStorageFilePath))
  end if
end repeat

###Finderを前面に
set strBundleID to "com.apple.finder" as text
set ocidRunningApplication to refMe's NSRunningApplication
set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID))
set ocidApp to ocidAppArray's firstObject()
ocidApp's activateWithOptions:(refMe's NSApplicationActivateAllWindows)
repeat 10 times
  set boolActive to ocidApp's active
  if boolActive = (refMe's NSNumber's numberWithBool:true) then
    exit repeat
  else
    delay 0.5
    set boolDone to ocidApp's activateWithOptions:(refMe's NSApplicationActivateIgnoringOtherApps)
  end if
end repeat
return "処理終了"


|

[CloudStorage]クラウド・ストレージを開く(iCloudに対応)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidCloudStorageURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:"CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
set ocidPathArray to item 1 of listPathUrlArray

####################################
##ディレクトリ名を取得
####################################
set listDirName to {"iCloud Drive"} as list

repeat with itemPathArray in ocidPathArray
  set ocidDirName to itemPathArray's lastPathComponent()
  set strDirName to ocidDirName as text
  copy strDirName to end of listDirName
end repeat


####################################
##ダイアログ
####################################

###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
try
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  else
    ####スクリプトエディタから実行したら
    tell current application
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  end if
on error
  log "エラーしました"
return "エラーしました"
  error "エラーしました" number -200
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
  error "キャンセルしました" number -200
end if
####ワークスペース初期化
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
####ダイアログで選択した数だけ繰り返し
repeat with itemResponse in listResponse
  set strResponse to itemResponse as text
  
  if strResponse is "iCloud Drive" then
    set ocidiCloudFilePathURL to (ocidUserLibraryPathURL's URLByAppendingPathComponent:("Mobile Documents") isDirectory:true)
    set ocidiCloudFilePath to ocidiCloudFilePathURL's |path|
(appSharedWorkspace's selectFile:(missing value) inFileViewerRootedAtPath:(ocidiCloudFilePath))
  else
    ###URLにして
    set ocidCloudStorageFilePathURL to (ocidCloudStorageURL's URLByAppendingPathComponent:(strResponse))
    set ocidCloudStorageFilePath to ocidCloudStorageFilePathURL's |path|
    ###開く
(appSharedWorkspace's selectFile:(missing value) inFileViewerRootedAtPath:(ocidCloudStorageFilePath))
  end if
end repeat


return "処理終了"


|

[BOX]デスクトップにクラウドストレージアイコン

ダウンロード - boxicon.zip


単体では動作しません
試す時は↑をダウンロードしてください


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

####################################
###ドコ?に作る?
set strAddAliasFilePath to "~/Desktop/Box" as text

###アイコンどうする?
set boolSetIcon to true as boolean
if boolSetIcon is true then
  set strIconFilePath to "/Applications/Box.app/Contents/Resources/Sync.icns" as text
end if

####################################
####エイリアスが作られる場所
set ocidAddAliasFilePathStr to refMe's NSString's stringWithString:strAddAliasFilePath
set ocidAddAliasFilePath to ocidAddAliasFilePathStr's stringByStandardizingPath
set ocidAddAliasFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidAddAliasFilePath isDirectory:false
set strAddAliasFilePathURL to ocidAddAliasFilePathURL's |path|() as text

###ディレクトリを作る必要があれば作る
set ocidAddAliasDirFilePathURL to ocidAddAliasFilePathURL's URLByDeletingLastPathComponent()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidAddAliasDirFilePathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)

####################################
####エイリアスの元ファイル
####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidCloudStorageURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:"CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
set ocidPathArray to item 1 of listPathUrlArray


####################################
##ディレクトリ名を取得
####################################
set listDirName to {} as list

repeat with itemPathArray in ocidPathArray
  set ocidDirName to itemPathArray's lastPathComponent()
  set strDirName to ocidDirName as text
  if strDirName starts with "Box" then
    copy strDirName to end of listDirName
  end if
end repeat
####################################
##ダイアログ
####################################

###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
try
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  else
    ####スクリプトエディタから実行したら
    tell current application
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
    end tell
  end if
on error
  log "エラーしました"
  return "エラーしました"
  error "エラーしました" number -200
end try
if (item 1 of listResponse) is false then
  return "キャンセルしました"
  error "キャンセルしました" number -200
end if

####################################
#### 受け取ったディレクトリ
####################################
set strResponse to item 1 of listResponse as text
###URLにして
set ocidFilePathURL to (ocidCloudStorageURL's URLByAppendingPathComponent:strResponse)

####################################
#### エイリアスを作る
####################################
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidAddAliasFilePathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))

####################################
#### アイコンを付与
####################################
if boolSetIcon is true then
  tell application "Finder"
    set aliasIconFilePath to (path to me) as alias
    set aliiasContainerDirPath to container of aliasIconFilePath as alias
  end tell
  set strIconPath to (POSIX path of aliiasContainerDirPath) as text
  set strBinPath to (strIconPath & "bin/seticon") as text
  set strCommandText to ("\"" & strBinPath & "\" \"" & strIconFilePath & "\" \"" & strAddAliasFilePathURL & "\"") as text
  do shell script strCommandText
end if

return

|

Google Driveエイリアスをデスクトップに出す

ダウンロード - google20drive.zip

↑試す場合はこちらをダウンロードして実行してください
中にコマンドツールが同封されています


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

####################################
###ドコ?に作る?
set strAddAliasFilePath to "~/Desktop/Google Drive" as text

###アイコンどうする?
set boolSetIcon to true as boolean
if boolSetIcon is true then
  set strIconFilePath to "/Applications/Google Drive.app/Contents/Resources/drive_fs.icns" as text
end if

####################################
####エイリアスが作られる場所
set ocidAddAliasFilePathStr to refMe's NSString's stringWithString:strAddAliasFilePath
set ocidAddAliasFilePath to ocidAddAliasFilePathStr's stringByStandardizingPath
set ocidAddAliasFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidAddAliasFilePath isDirectory:false
set strAddAliasFilePathURL to ocidAddAliasFilePathURL's |path|() as text

###ディレクトリを作る必要があれば作る
set ocidAddAliasDirFilePathURL to ocidAddAliasFilePathURL's URLByDeletingLastPathComponent()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidAddAliasDirFilePathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)

####################################
####エイリアスの元ファイル
####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidCloudStorageURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:"CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
set ocidPathArray to item 1 of listPathUrlArray


####################################
##ディレクトリ名を取得
####################################
set listDirName to {} as list

repeat with itemPathArray in ocidPathArray
  set ocidDirName to itemPathArray's lastPathComponent()
  set strDirName to ocidDirName as text
  if strDirName starts with "GoogleDrive" then
    copy strDirName to end of listDirName
  end if
end repeat
####################################
##ダイアログ
####################################

###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
try
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  else
    ####スクリプトエディタから実行したら
    tell current application
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
    end tell
  end if
on error
  log "エラーしました"
  return "エラーしました"
  error "エラーしました" number -200
end try
if (item 1 of listResponse) is false then
  return "キャンセルしました"
  error "キャンセルしました" number -200
end if

####################################
#### 受け取ったディレクトリ
####################################
set strResponse to item 1 of listResponse as text
###URLにして
set ocidFilePathURL to (ocidCloudStorageURL's URLByAppendingPathComponent:strResponse)

####################################
#### エイリアスを作る
####################################
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidAddAliasFilePathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))

####################################
#### アイコンを付与
####################################
if boolSetIcon is true then
  tell application "Finder"
    set aliasIconFilePath to (path to me) as alias
    set aliiasContainerDirPath to container of aliasIconFilePath as alias
  end tell
  set strIconPath to (POSIX path of aliiasContainerDirPath) as text
  set strBinPath to (strIconPath & "bin/seticon") as text
  set strCommandText to ("\"" & strBinPath & "\" \"" & strIconFilePath & "\" \"" & strAddAliasFilePathURL & "\"") as text
  do shell script strCommandText
end if

return

|

[CloudStorage]クラウドドライブを開く

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidCloudStorageURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:"CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
set ocidPathArray to item 1 of listPathUrlArray

####################################
##ディレクトリ名を取得
####################################
set listDirName to {} as list

repeat with itemPathArray in ocidPathArray
  set ocidDirName to itemPathArray's lastPathComponent()
  set strDirName to ocidDirName as text
  copy strDirName to end of listDirName
end repeat


####################################
##ダイアログ
####################################

###ダイアログを前面に出す
tell current application
  set strName to name as text
end tell
try
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  else
    ####スクリプトエディタから実行したら
    tell current application
      activate
      set listResponse to (choose from list listDirName with title "選んでください" with prompt "クラウドストレージを開きます" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed without empty selection allowed) as list
    end tell
  end if
on error
  log "エラーしました"
  return "エラーしました"
  error "エラーしました" number -200
end try
if (item 1 of listResponse) is false then
  return "キャンセルしました"
  error "キャンセルしました" number -200
end if
####ワークスペース初期化
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
####ダイアログで選択した数だけ繰り返し
repeat with itemResponse in listResponse
  set strResponse to itemResponse as text
  ###URLにして
  set ocidCloudStoragDireURL to (ocidCloudStorageURL's URLByAppendingPathComponent:strResponse)
  ###開く
  (appSharedWorkspace's openURL:ocidCloudStoragDireURL)
end repeat


return "処理終了"

|

[CloudStorage]クラウドドライブを開く

複数アカウントに対応した
CloudStorageの複数アカウントは
『サービス名』-『アカウント名』となっている
OneDriveなら
OneDrive-個人用 OneDrive-企業名 OneDrive-組織名
GoogleDriveなら
GoogleDrive-メールアドレス
Boxなら
Box-Boxが個人用 Box-アカウント名が組織用



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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application

####設定
set strDriveName to "GoogleDrive" as text
(*
set strDriveName to "Box"
set strDriveName to "OneDrive"
set strDriveName to "DropBox"
set strDriveName to "GoogleDrive"
*)


set appFileManager to refMe's NSFileManager's defaultManager()
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()

###################################
#####パス
###################################
set ocidHomeDirUrl to appFileManager's homeDirectoryForCurrentUser()
set ocidCloudStorageDirURL to ocidHomeDirUrl's URLByAppendingPathComponent:"Library/CloudStorage"

###################################
#####複数アカウントあるか調べる
###################################
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageDirURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
###Arrayに格納
set ocidPathUrlArray to item 1 of listPathUrlArray
###パス格納用のArrayを作って
set ocidPathArray to (refMe's NSMutableArray's arrayWithCapacity:0)
####コンテンツの数だけ繰り返し
repeat with itemPathUrlArray in ocidPathUrlArray
  ###最後のパスを取得して
  set ocidLastPathName to itemPathUrlArray's lastPathComponent()
  ###テキストに
  set strLastPathName to ocidLastPathName as text
  ###最後のパスにBoxが含まれていたら
  if strLastPathName starts with strDriveName then
    ###Arrayに格納
    (ocidPathArray's addObject:itemPathUrlArray)
  end if
end repeat
###################################
#####複数アカウント時
###################################
set numCntArray to (ocidPathArray count) as integer
#####アカウント数0
if numCntArray = 0 then
  return "CloudStorageに対象のアカウントがありません。ソフトウェアをアップデートしてください"
  ####アカウント数1
else if numCntArray = 1 then
  set ocidFilePathURL to ocidPathArray's objectAtIndex:0
  set aliasFilePathURL to ocidFilePathURL as alias
  set boolResults to (appShardWorkspace's openURL:ocidFilePathURL)
  if boolResults is false then
    tell application "Finder"
      make new Finder window to aliasFilePathURL
    end tell
  end if
  return "処理終了"
else
  ####複数アカウント
  set listDirName to {} as list
  repeat with itemPathArray in ocidPathArray
    set strDirName to (itemPathArray's lastPathComponent()) as text
    copy strDirName to end of listDirName
  end repeat
  ####ダイアログを前面に出す
  tell current application
    set strName to name as text
  end tell
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder"
      activate
    end tell
  else
    tell current application
      activate
    end tell
  end if
  try
    set listResponse to (choose from list listDirName with title "選んでください" with prompt "開くフォルダを選んでください" default items (item 1 of listDirName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed)
    log class of listResponse
  on error
    log "エラーしました"
    return "エラーしました"
  end try
  if listResponse is false then
    return "キャンセルしました"
  end if
  set itemPathArray to (item 1 of listResponse) as text
  set ocidCloudStorageDirURL to ocidCloudStorageDirURL's URLByAppendingPathComponent:strDirName
end if

###################################
#####開く
###################################
repeat with itemPathArray in ocidPathArray
  set aliasFilePathURL to itemPathArray as alias
  set boolResults to (appShardWorkspace's openURL:itemPathArray)
  if boolResults is false then
    tell application "Finder"
      make new Finder window to aliasFilePathURL
    end tell
  end if
end repeat

return "選択オープン処理終了"





|

[OneDrive]デスクトップにOneDriveのエイリアスをアイコン付きで作成する

こんな感じでデスクトップにエイリアスを作ります
Screencapture-20230407-02831



ダウンロード - onedriveicon.zip




↓単体では動作しません。必ず↑をダウンロードして使ってください
(中にアイコンファイル用のコマンドが内包されています)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

################################################
####クラウドストレージ内のOneDriveフォルダが複数ある場合対応
################################################
##ホームディレクトリ
set ocidHomeDirUrl to appFileManager's homeDirectoryForCurrentUser()
###クラウドストレージ
set ocidCloudStorageDirURL to ocidHomeDirUrl's URLByAppendingPathComponent:"Library/CloudStorage"
###プロパティ設定
set ocidPropertieKey to {(refMe's NSURLPathKey), (refMe's NSURLIsDirectoryKey)}
###オプション設定
set ocidOption to refMe's NSDirectoryEnumerationSkipsHiddenFiles
###ディレクトリのコンテンツを取得(第一階層のみ)
set listPathUrlArray to (appFileManager's contentsOfDirectoryAtURL:ocidCloudStorageDirURL includingPropertiesForKeys:ocidPropertieKey options:ocidOption |error|:(reference))
###Arrayに格納
set ocidPathUrlArray to item 1 of listPathUrlArray
###パス格納用のArrayを作って
set ocidPathArray to (refMe's NSMutableArray's arrayWithCapacity:0)
####コンテンツの数だけ繰り返し
repeat with itemPathUrlArray in ocidPathUrlArray
  ###最後のパスを取得して
  set ocidLastPathName to itemPathUrlArray's lastPathComponent()
  ###テキストに
  set strLastPathName to ocidLastPathName as text
  ###最後のパスにOneDriveが含まれていたら
  if strLastPathName starts with "OneDrive" then
    ###そのパスをUNIXパス形式で
    set ocidDirPath to itemPathUrlArray's |path|()
    ###Arrayに格納
    (ocidPathArray's addObject:ocidDirPath)
  end if
end repeat


####################################
###アイコンのパス
set strIconFilePath to "/Applications/OneDrive.app/Contents/Resources/OneDrive.icns" as text

####################################
####エイリアスが作られる場所 デスクトップ
set ocidDesktopFilePathURL to ocidHomeDirUrl's URLByAppendingPathComponent:"Desktop"

################################################
####クラウドストレージ内のOneDriveフォルダの数だけ繰り返し
################################################
repeat with itemPathArray in ocidPathArray
  set strItemPath to itemPathArray as text
  ####################################
  ####エイリアスの元ファイル
  ####################################
  set ocidFilePathStr to (refMe's NSString's stringWithString:strItemPath)
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
  set ocidDirName to ocidFilePathURL's lastPathComponent()
  ###デスクトップにフォルダ名を追加してエリアスのパスに
  set ocidAddAliasFilePathURL to (ocidDesktopFilePathURL's URLByAppendingPathComponent:ocidDirName)
  set strAddAliasFilePathURL to ocidAddAliasFilePathURL's |path|() as text
  
  ####################################
  #### エイリアスを作る
  ####################################
  set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
  set ocdiBookMarkData to (item 1 of listBookMarkNSData)
  set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidAddAliasFilePathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))
  
  ####################################
  #### アイコンを付与
  ####################################
  tell application "Finder"
    set aliasIconFilePath to (path to me) as alias
    set aliiasContainerDirPath to container of aliasIconFilePath as alias
  end tell
  set strIconPath to (POSIX path of aliiasContainerDirPath) as text
  set strBinPath to (strIconPath & "bin/seticon") as text
  set strCommandText to ("\"" & strBinPath & "\" \"" & strIconFilePath & "\" \"" & strAddAliasFilePathURL & "\"") as text
  do shell script strCommandText
end repeat

return

|

[DropBox]DropBoxフォルダへバックアップしたいフォルダをコピーする

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application


set appFileManager to refMe's NSFileManager's defaultManager()


###################################
#####入力フォルダ
###################################
set ocidHomeDirUrl to appFileManager's homeDirectoryForCurrentUser()
set ocidDesktopDirURL to ocidHomeDirUrl's URLByAppendingPathComponent:"Desktop"
set aliasDesktopDirURL to ocidDesktopDirURL as alias
###ダイアログテキスト
set strPromptText to "入力フォルダを選んでください"
set strPromptMes to "入力フォルダを選んでください"
try
  set listResponse to (choose folder strPromptMes with prompt strPromptText default location aliasDesktopDirURL with invisibles and showing package contents without multiple selections allowed) as list
on error
  log "エラーしました"
  return
end try
set aliasCopyDirPath to (item 1 of listResponse) as alias
###################################
#####コピー先フォルダ
###################################
set ocidDropBoxDirURL to ocidHomeDirUrl's URLByAppendingPathComponent:"Library/CloudStorage/Dropbox"
set aliasDropBoxDirURL to ocidDropBoxDirURL as alias
###ダイアログテキスト
set strPromptText to "コピー先フォルダを選んでください"
set strPromptMes to "コピー先フォルダを選んでください"
try
  set listDistResponse to (choose folder strPromptMes with prompt strPromptText default location aliasDropBoxDirURL with invisibles and showing package contents without multiple selections allowed) as list
on error
  log "エラーしました"
  return
end try
set aliasDistDirPath to (item 1 of listDistResponse) as alias


###################################
#####コマンド実行
###################################
###dittoコマンドの特性に合わせてパスを調整
###入力パスから最後のディレクトリ名を取得して
set strCopyDirPath to POSIX path of aliasCopyDirPath as text
set ocidCopyDirPathStr to refMe's NSString's stringWithString:strCopyDirPath
set ocidCopyDirPath to ocidCopyDirPathStr's stringByStandardizingPath()
set ocidLastDirName to ocidCopyDirPath's lastPathComponent()
####出力先パスの最後に加える
set strDistDirPath to POSIX path of aliasDistDirPath as text
set ocidDistDirPathStr to refMe's NSString's stringWithString:strDistDirPath
set ocidDistDirPath to ocidDistDirPathStr's stringByStandardizingPath()
set ocidDistDirPath to ocidDistDirPath's stringByAppendingPathComponent:ocidLastDirName
set strDistDirPathStr to ocidDistDirPath as text


set strCommandText to "/usr/bin/ditto \"" & strCopyDirPath & "\" \"" & strDistDirPathStr & "\"" as text
do shell script strCommandText



|

[DropBox]デスクトップにDropBoxのエイリアスをアイコン付きで作成する

ダウンロード - dropboxicon.zip



↓単体では動作しません。必ず↑をダウンロードして使ってください
(中にアイコンファイル用のコマンドが内包されています)

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

####################################
###ドコ?に作る?
set strAddAliasFilePath to "~/Desktop/Dropbox" as text
###元ファイルは?
set strOrgFilePath to "~/Library/CloudStorage/Dropbox" as text
###アイコンどうする?
set boolSetIcon to true as boolean

if boolSetIcon is true then
  set strIconFilePath to "/Applications/Dropbox.app/Contents/Resources/AppIcon.icns" as text
end if

####################################
####エイリアスが作られる場所
set ocidAddAliasFilePathStr to refMe's NSString's stringWithString:strAddAliasFilePath
set ocidAddAliasFilePath to ocidAddAliasFilePathStr's stringByStandardizingPath
set ocidAddAliasFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidAddAliasFilePath isDirectory:false
set strAddAliasFilePathURL to ocidAddAliasFilePathURL's |path|() as text

###ディレクトリを作る必要があれば作る
set ocidAddAliasDirFilePathURL to ocidAddAliasFilePathURL's URLByDeletingLastPathComponent()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidAddAliasDirFilePathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)

####################################
####エイリアスの元ファイル
####################################
set ocidFilePathStr to refMe's NSString's stringWithString:strOrgFilePath
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false

####################################
#### エイリアスを作る
####################################
set listBookMarkNSData to (ocidFilePathURL's bookmarkDataWithOptions:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) includingResourceValuesForKeys:{refMe's NSURLCustomIconKey} relativeToURL:(missing value) |error|:(reference))
set ocdiBookMarkData to (item 1 of listBookMarkNSData)
set listResults to (refMe's NSURL's writeBookmarkData:ocdiBookMarkData toURL:ocidAddAliasFilePathURL options:(refMe's NSURLBookmarkCreationSuitableForBookmarkFile) |error|:(reference))

####################################
#### アイコンを付与
####################################
if boolSetIcon is true then
  tell application "Finder"
    set aliasIconFilePath to (path to me) as alias
    set aliiasContainerDirPath to container of aliasIconFilePath as alias
  end tell
  set strIconPath to (POSIX path of aliiasContainerDirPath) as text
  set strBinPath to (strIconPath & "bin/seticon") as text
  set strCommandText to ("\"" & strBinPath & "\" \"" & strIconFilePath & "\" \"" & strAddAliasFilePathURL & "\"") as text
  do shell script strCommandText
end if

return

|

[Icon]エイリアスファイルにアイコン貼って→出ないようにする

要はこうゆう事です

_20220314_19_18_42
osxiconutilsを利用しています
https://github.com/sveinbjornt/osxiconutils

ダウンロード - makecloudstorageicon.zip




#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#osxiconutilsを使用しています許諾は以下を参照ください
#https://github.com/sveinbjornt/osxiconutils
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.6"
use framework "Foundation"
use scripting additions





tell application "Finder"
set theBinDir to POSIX path of (folder "bin" of (container of (path to me)) as alias) as text
end tell

set theBinFile to ("\"" & theBinDir & "seticon\"") as text
log theBinFile

tell application "Finder"
set aliasCloudStorageDir to (folder "Creative Cloud Files" of (path to home folder from user domain)) as alias



set theFolderName to name of aliasCloudStorageDir as text
make new alias to folder aliasCloudStorageDir at (path to desktop folder from user domain)
try
set name of result to theFolderName
on error
log "すでに同名のファイルかフォルダかエイリアスがあります"
end try
set theDistPath to POSIX path of (path to desktop folder from user domain)
end tell

set theDistPath to ("\"" & theDistPath & "" & theFolderName & "\"")

log theBinFile

set strIconPath to "\"/Applications/Utilities/Adobe Sync/CoreSync/Core Sync.app/Contents/Resources/creativecloud_folder.icns\""

set strCommandText to "" & theBinFile & " " & strIconPath & " " & theDistPath & ""
log strCommandText
do shell script strCommandText

set strCommandText to "" & theBinFile & " " & strIconPath & " \"$HOME/Creative Cloud Files\""
log strCommandText
do shell script strCommandText

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC 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 webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom