« [NSURLIsUserImmutableKey]フォルダをロックする | トップページ | Adobe DNG Converter »

[moveItemAtURL]フォルダの移動

#!/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

property refNSString : a reference to refMe's NSString

property refNSURL : a reference to refMe's NSURL

property refNSWorkspace : a reference to refMe's NSWorkspace


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


###################################

#####入力フォルダ

###################################

###ダイアログのデフォルト

set ocidUserDesktopPath to (objFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))

set aliasDefaultLocation to ocidUserDesktopPath as alias

tell application "Finder"

  ##  set aliasDefaultLocation to container of (path to me) as alias

end tell

###ダイアログテキスト

set strPromptText to "入力フォルダを選んでください"

try

  set listResponse to (choose folder strPromptText with prompt strPromptText default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents) as list

on error

  log "エラーしました"

  return

end try

###エリアス

set aliasDirPath to (item 1 of listResponse) as alias

###UNIXパス

set strDirPath to POSIX path of aliasDirPath as text

###String

set ocidDirPath to refNSString's stringWithString:strDirPath

###NSURL

set ocidDirPathURL to refNSURL's alloc()'s initFileURLWithPath:ocidDirPath isDirectory:true

###フォルダ名

set ocidFileName to ocidDirPathURL's lastPathComponent()




#####移動先

set strFilePath to "~/Creative Cloud Files"

set ocidFilePath to refNSString's stringWithString:strFilePath

set ocidFilePath to ocidFilePath's stringByStandardizingPath

set ocidFilePathURL to (refNSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:true)

set ocidFileDistPathURL to ocidFilePathURL's URLByAppendingPathComponent:ocidFileName


###移動する

set listResults to objFileManager's moveItemAtURL:ocidDirPathURL toURL:ocidFileDistPathURL |error|:(reference)


###Finderで開く

set ocidShardWorkspace to refNSWorkspace's sharedWorkspace()

ocidShardWorkspace's openURL:ocidFilePathURL




|

« [NSURLIsUserImmutableKey]フォルダをロックする | トップページ | Adobe DNG Converter »

AppleScript Folder」カテゴリの記事