• 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
Re: Changing the name of a file in the temporary items folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the name of a file in the temporary items folder


  • Subject: Re: Changing the name of a file in the temporary items folder
  • From: Ed Stockly <email@hidden>
  • Date: Sat, 8 Dec 2007 09:39:55 -0800


Anyone can add false restrictions to a task.



I don't find those restrictions unusual. I'm often having scripts jump through hoops to play nicely in a multiplatform, multidepartment environment. 

 Based on how this thread has evolved, here's how I would solve this little puzzle: 

----------
set originalFile to (choose file)
set newFileName to "bar.txt"
set fileDestination to path to desktop as alias

set movedFile to SpecialMoveRename(originalFile, fileDestination, newFileName)

on SpecialMoveRename(originalFile, fileDestination, newFileName)
 set folderRoot to the name of me
 set tempPath to path to temporary items as string
 set x to 1
 repeat
  set myTempFolderName to folderRoot & "-" & x as string
  try
   set myTempFolderPath to (tempPath & myTempFolderName) as alias
   set x to x + 1
  on error
   tell application "Finder"
    set myTempFolder to (make new folder at tempPath with properties {name:myTempFolderName}) as alias
    exit repeat
   end tell
  end try
 end repeat
 tell application "Finder"
  set tempFile to (move originalFile to myTempFolder with replacing) as alias
  set the name of tempFile to newFileName
  set newFile to (move tempFile to fileDestination with replacing) as alias
  delete myTempFolder
  return newFile
 end tell
end SpecialMoveRename

 ----------
You can take the SpecialMoveRename handler, modify it, optimize it, customize it, change the variable names to completely unintelligible nonsense, if you like, then save it in a handler collection, or put it in a library, and it will always be there any time you have to move a file with a new name, without having the new name appear in the source directory or the old name appear in the destination directory.

ES

=
 _______________________________________________
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: Changing the name of a file in the temporary items folder
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: AppleScript-Users Digest, Vol 4, Issue 626
  • Next by Date: Re: Changing the name of a file in the temporary items folder
  • Previous by thread: Re: Changing the name of a file in the temporary items folder
  • Next by thread: Re: Changing the name of a file in the temporary items folder
  • Index(es):
    • Date
    • Thread