automator/applescript hulp nodig
14 april 2009 - 17:26   
geplaatst door: Box4you
beste allen,

ik zou een Automator (of Apple) script willen maken dat het volgende doet:

Stap 1: script vraagt in de finder naar een naam (vb: 09-ABC-1234)
Stap 2: script opent een txt file in een specifieke folder die de naam draagt, ingegeven in stap 1
Stap 3: script copieert de inhoud van de net geopende tekstfile (hierin staat een path dat we later nodig hebben)
Stap 4: script sluit de net geopende tekstfile
Stap 5: script opent het findercommando 'Go to folder ...'
Stap 6: script plakt de inhoud (het path) van de eerder geopende tekstfile hierin en activeert (Go) het.


Wie kan me hierbij helpen?

automator/applescript hulp nodig
14 april 2009 - 19:03    reactie #1
geplaatst door: AndreRelink
Hallo,

Stap 6, is nog niet geheel duidelijk, wat bedoel je hiermee?

Alvast een opzet van een applescript (plak de code in Scripteditor.app)

tell application "TextEdit"
set docCount to count of documents
if docCount > 0 then
display dialog "Sluit eerst alle documenten in TextExit!" buttons {"Cancel"}
else
tell application "Finder"
set myText to choose file with prompt "Kies een file"
end tell
open myText
set myTextContent to every paragraph of last document
close last document
tell application "Finder"
set myFolder to choose folder with prompt "Kies de folder"
end tell
set newDoc to make new document
set text of newDoc to (myTextContent as text)
save newDoc in (myFolder as Unicode text)
end if
end tell

Succes André

(Bewerkt door AndreRelink om 19:05, 14-04-2009)

automator/applescript hulp nodig
14 april 2009 - 23:34    reactie #2
geplaatst door: Willemien
nog een voorzet: (plak in Scripteditor en pas aan naar wens)

tell application "Finder"
-- Stap 1: script vraagt in de finder naar een naam (vb: 09-ABC-1234)
set myFolder to choose folder with prompt "Kies de map" default location path to desktop folder

-- bepaal de file voor stap 2
set myTxtFilePath to (file "eentxtfile.txt" of folder myFolder) as alias
end tell

-- Stap 2: script opent een txt file in een specifieke folder die de naam draagt, ingegeven in stap 1
set myFile to open for access myTxtFilePath

-- Stap 3: script copieert de inhoud van de net geopende tekstfile (hierin staat een path dat we later nodig hebben)
set myGoToFolder to read myFile

-- Stap 4: script sluit de net geopende tekstfile
close access myFile

-- in plaats van stap 5 en 6: doe net zoiets als 'Go to folderÂ…'
tell application "Finder"
if number of windows > 0 then
set target of window 1 to POSIX file myGoToFolder
else
reveal (POSIX file myGoToFolder) as text
end if
end tell

het gaat uit van een path met /