• 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
Renaming files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Renaming files


  • Subject: Renaming files
  • From: Thomas Fischer <email@hidden>
  • Date: Tue, 05 Apr 2011 09:15:43 +0200

Hello,

I have a script that edits a text file and then renames the file.
While the change of  text works nicely, I have problems with the renaming.
The process is as follows: I open the file using TextWrangler, let it do the text mangling and save and close the file.
I extract a name from the text and then do something like

tell application "Finder"
	delay 1
	try
		if newName ≠ "" then
			set the name of myFile to (newName & ".txt")
		else
			set the name extension of myFile to "txt"
		end if
	on error theErr
		display dialog theErr
	end try
end tell

I added the delay, since without it the renaming didn't seem to work, but even with "delay 3" some (most?) files aren't renamed.
There is never an error message.

If I replace the Finder call by

tell application "System Events"

then the file is renamed correctly, even without delay, but the Spotlight comments are lost, which I'd like to preserve.

Does anybody have an idea what goes wrong and /or how to make it work?

All the best
Thomas _______________________________________________
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

  • Prev by Date: Re: Very Irritating Open Handler
  • Next by Date: Re: Very Irritating Open Handler
  • Previous by thread: Getting Mail ID
  • Next by thread: Re:Renaming files
  • Index(es):
    • Date
    • Thread