• 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: Folder action when modifying a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Folder action when modifying a file


  • Subject: Re: Folder action when modifying a file
  • From: Victor <email@hidden>
  • Date: Sun, 25 Apr 2010 15:50:47 +0200


Il giorno 25/apr/2010, alle ore 12.32, Yvan KOENIG ha scritto:


Le 25 avr. 2010 à 12:11, Victor a écrit :


while writing a document in Pages09  I'd like to save it from time to time via File->Save (or command-s) and have  it saved also as rich text format by an automatically triggered AS.

With the following AS script (working draft) 

on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
set the folder_name to the name of this_folder
end tell
get info for item 1 of added_items
set nomefile to name of result
if nomefile ends with ".pages" then
set nomefile to text 1 thru -6 of the nomefile
set nomefile to nomefile & "rtf"
tell application "Pages"
save front document as ¬
"SLDocumentTypeRichText" in "Macintosh HD:Users:victor:Desktop:Folder:" & nomefile
end tell
end if
end try
end adding folder items to

Unfortunately it works only once that is when I save a document with a new file name for the first time in that folder .  If I goes on writing and saving the same file nothing happens, apparently because non new items have been added to the folder. 
How can I make AS folder action sensitive also the variation of size of the file in the folder (or better, when I save during an editing session, also the folder changes its size). 

If I understand well, the problem is that there is already a file with the given name.
My own tip is to use a date_time stamped file name.
to do that, I would replace the line:
set nomefile to nomefile & "rtf"
by
set nomefile to nomefile & (do shell script "date +_%Y%m%d-%H%M%S") & ".rtf"

Yvan KOENIG (VALLAURIS, France) dimanche 25 avril 2010 12:31:04

Yvan,
Perhaps I did not put my question clear.
Suppose you are editing a document in Pages 09  and you save it the first time - in the folder in which that AS  folder action is active - as "test.pages". Immediatedly the script starts and you find a "test.rtf" in the same folder (and perhaps it starts a second time because of the newly created "test.rtf" file without consequence) . Great ...But while going on editing your file "test.pages" in Pages and, as a good habit,  from time to time saving it with file->save (therefore, you're saving a modified version of the same "test.pages")  nothing happens, I mean the script doesn't start at all because, I guess, the content of the folder is "formally" unchanged, that is it contains the same list of files even though "test.pages" has been changed. My aim is to make the script start every time I save a modified version of "test.pages" in order to have a refreshed "test.rtf" file side by side in the same folder.
Arrivederci from Rome and Au Revoir
Victor

 
 _______________________________________________
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: Folder action when modifying a file
      • From: Yvan KOENIG <email@hidden>
References: 
 >Folder action when modifying a file (From: Victor <email@hidden>)
 >Re: Folder action when modifying a file (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Reveal the tables of a sheet in Numbers
  • Next by Date: Re: Folder action when modifying a file
  • Previous by thread: Re: Folder action when modifying a file
  • Next by thread: Re: Folder action when modifying a file
  • Index(es):
    • Date
    • Thread