Hi all,
Pls. bear with me…I am a newbie at this.
What I wish to do is to run an applescript automatically on ALL files that are put into a specific folder called “Crissi’s Converter”
What this converter does is change the style of all text within a document to a specified font, size, justification, etc. that we need our final file versions to be in before our editor takes them for editing.
I understand that a “folder action” is needed to attach to the folder called “Crissi’s Converter.”
At present, all I have been able to get to work successfully is to have the file open in the app Tex-Edit, to begin with, before I run the script. I am still brand new with most commands.
As I said, my intent is for the script to be applied automatically to all files put within that folder.
Is there anyone that can help me out here…perhaps write a small part of the script, or at least tell me what the command is to “open all files of a certain type within a certain folder.” Does this make sense?
I have also tried to get this going thru automator but am having no luck. Maybe I should post this in the Automator forum? Perhaps it will be easier to run this as a workflow.
In advance, your help is much MUCH appreciated:))
(Here is what I have so far for the script)
tell application “Tex-Edit Plus”
activate
select contents of window 1
set font of selection to “Courier”
set size of selection to 18
set line spacing of selection to 0.0
set space above of selection to 0
set space below of selection to 0
set left indent of selection to 0
set right indent of selection to 0
set first indent of selection to 50
set bottom border of selection to none
set justification of selection to left
set text direction of selection to default
save window 1 with creator «class TBB6»
end tell
Model: Powermac G5
AppleScript: 1.10
Browser: Safari 412.2
Operating System: Mac OS X (10.4)
More specifically, you might like to try something like this adaptation of your script:
on adding folder items to after receiving fileList
tell application "Tex-Edit Plus"
launch
repeat with currFile in fileList
open currFile
tell window 1
tell contents
set font to "Courier"
set size to 18
set line spacing to 0.0
set space above to 0
set space below to 0
set left indent to 0
set right indent to 0
set first indent to 50
set bottom border to none
set justification to left
set text direction to default
end tell
save with creator «class TBB6»
close
end tell
end repeat
end tell
end adding folder items to
Thank you SO MUCH!! This works PERFECTLY!! As soon as I drop files into the folder after attaching the script as a folder action, it works just as it should!! The only thing I left out was the line “set invisibles displayed to true” but once I added this in, the script no longer worked correctly and I do not know what I am doing wrong:(
I changed the script to read:
on adding folder items to after receiving fileList
tell application “Tex-Edit Plus”
launch
repeat with currFile in fileList
open currFile
tell window 1
tell contents
set font to “Courier”
set size to 18
set line spacing to 0.0
set space above to 0
set space below to 0
set left indent to 0
set right indent to 0
set first indent to 50
set invisibles displayed to true
set bottom border to none
set justification to left
set text direction to default
end tell
save with creator «class TBB6»
close
end tell
end repeat
end tell
end adding folder items to
Just a slight misunderstanding - in that ‘invisibles displayed’ is a window property, rather than a text property. Moving the statement from the ‘tell contents’ [of window 1] directly to the ‘tell window 1’ block should fix it (although I’m not sure that the setting will be preserved in a save):
on adding folder items to after receiving fileList
tell application "Tex-Edit Plus"
launch
repeat with currFile in fileList
open currFile
tell window 1
tell contents
set font to "Courier"
set size to 18
set line spacing to 0.0
set space above to 0
set space below to 0
set left indent to 0
set right indent to 0
set first indent to 50
set bottom border to none
set justification to left
set text direction to default
end tell
set invisibles displayed to true
save with creator «class TBB6»
close
end tell
end repeat
end tell
end adding folder items to
Kai,
I want to thank you very much for taking the time out to help me with this. I really really appreciate it! I wish I had known to post here earlier…I was battling with this for a while, and after your first post everything just fell into place and it worked exactly as I had been intending for it to do!
Have a wonderful weekend!
(BTW, that last setting I had asked about was not preserved in the safe…but that is really a minor thing anyway.)
If it’s any consolation, you’ll probably remember the stuff that you struggled with much better than if you found the solution immediately. (I usually do, anyway!)
Right. I didn’t have any time to check this when I replied - so I was going on my memory of Tex-Edit Plus’s behaviour. Not much we can do about that one, I’m afraid.
Incidentally, if anyone hasn’t yet tried using Tex-Edit Plus as a text editor, I can highly recommend it. It’s eminently scriptable - and recordable, to boot. Its AppleScript implementation is (IMO) second to none. (And no, I don’t have any affiliation with its author, Tom Bender.) You can download Tex-Edit Plus at http://www.tex-edit.com/