« Microsoft Fontsダウンロード | トップページ | FontBookからコピーした値からパスやPostscript名を取得する »

[NSPasteboard]ファイルパス ファイルURL

ファイルURL

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

#!/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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


########################
## クリップボードの中身取り出し
########################
###初期化
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
##中身の要素
set ocidPastBoardTypeArray to ocidPasteboard's types
##NSURL
set boolContain to ocidPastBoardTypeArray's containsObject:("public.file-url")
if boolContain is true then
  set ocidClassesArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidClassesArrayM's addObject:(refMe's NSURL)
  set ocidFilePathURLArray to ocidPasteboard's readObjectsForClasses:(ocidClassesArrayM) options:(missing value)
else if boolContain is false then
  set boolContain to ocidPastBoardTypeArray's containsObject:("NSFilenamesPboardType")
  if boolContain is true then
    set ocidFilePathArray to ocidPasteboard's propertyListForType:(refMe's NSFilenamesPboardType)
    set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
    repeat with itemArray in ocidFilePathArray
      set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(itemArray))
(ocidFilePathURLArray's addObject:(ocidFilePathURL))
    end repeat
  else
    set ocidFilePathURLArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
return "ファイルのパスの取得に失敗しました"
  end if
end if
log ocidFilePathURLArray as list

ファイルパス

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

#!/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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


########################
## クリップボードの中身取り出し
########################
###初期化
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
##中身の要素
set ocidPastBoardTypeArray to ocidPasteboard's types
#
set boolContain to ocidPastBoardTypeArray's containsObject:("NSFilenamesPboardType")
if boolContain is true then
  set ocidFilePathArray to ocidPasteboard's propertyListForType:(refMe's NSFilenamesPboardType)
  
else if boolContain is false then
  set boolContain to ocidPastBoardTypeArray's containsObject:("public.file-url")
  if boolContain is true then
    set ocidClassesArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidClassesArrayM's addObject:(refMe's NSURL)
    set ocidFilePathURLArray to ocidPasteboard's readObjectsForClasses:(ocidClassesArrayM) options:(missing value)
    set ocidFilePathArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
    repeat with itemArray in ocidFilePathURLArray
      set ocidFilePath to itemArray's |path|
(ocidFilePathArray's addObject:(ocidFilePath))
    end repeat
    
    
  end if
else
  set ocidFilePathArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
return "ファイルのパスの取得に失敗しました"
end if
log ocidFilePathArray as list


|

« Microsoft Fontsダウンロード | トップページ | FontBookからコピーした値からパスやPostscript名を取得する »

AppleScript NSPasteboard」カテゴリの記事