• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSFileManager problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSFileManager problem


  • Subject: NSFileManager problem
  • From: Takaaki Naganoya <email@hidden>
  • Date: Mon, 26 Oct 2015 16:55:52 +0900

Hi Folks,

I wrote an easy file manage AppleScript (AppleScript 1) to move files from shared folder by NSFileManager’s moveItemAtURL: toURL: error: method. Moving files from other user via network cased privilege related error.

So, I changed it to Finder version (AppleScript 2). 

Can we avoid such a error when we use NSFileManager ?



<AppleScript 1>
on moveFilesWithPOSIXstrList(aFileList, toFolStr)
set pathString to current application's NSString's stringWithString:toFolStr
set newPath to pathString's stringByExpandingTildeInPath()
set defM to current application's NSFileManager's defaultManager
repeat with i in aFileList
if (defM's isReadableFileAtPath:i) as boolean = true then
set fromPath to (current application's |NSURL|'s fileURLWithPath:i)


set fileName to fromPath's lastPathComponent()
set newPathStr to (newPath's stringByAppendingPathComponent:fileName)
set toPath to (current application's |NSURL|'s fileURLWithPath:newPathStr)


(defM's moveItemAtURL:fromPath toURL:toPath |error|:(missing value)) —Error!! (result was false not true)


else
log {"Can not get file”}—not caught here
end if
end repeat
end moveFilesWithPOSIXstrList
</AppleScript 1>


<AppleScript 2>
on moveFilesWithPOSIXstrList(aFileList, toFolStr)
set pathString to current application's NSString's stringWithString:toFolStr
set newPath to pathString's stringByExpandingTildeInPath()
set targFol to newPath as text


set aliasList to {}
repeat with i in aFileList
try
set the end of aliasList to (POSIX file i) as alias
on error


end try
end repeat


set targFolAlias to (POSIX file targFol) as alias


try
with timeout of 3600 seconds
tell application "Finder"
move aliasList to targFolAlias with replacing
end tell
end timeout
end try
end moveFilesWithPOSIXstrList
</AppleScript 2>

--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSFileManager problem
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Script Editor phantoms
  • Next by Date: Re: NSFileManager problem
  • Previous by thread: Re: Script Editor phantoms
  • Next by thread: Re: NSFileManager problem
  • Index(es):
    • Date
    • Thread