- Registriert
- 12.09.15
- Beiträge
- 2
Hallo zusammen,
ich versuche gerade ein Script zu erstellen welches eine markierte Datei (Abfrage der Variablen via Dialogfenster und durch eine Abfrage der Evernote Tags) umbennent und dann in Evernote importiert.
Ich hab mir aus dem Netz diverse Code Schnipsel zusammen gesucht und durch viel lesen und probieren bin ich schon relativ weit, jetzt hängts nur leider irgendwo...
Das Script läuft bis einschl. umbennen, dannach stoppt es.
Hier das Script:
tell application "Finder"
try
set ItemList to selection
repeat with i from 1 to count of ItemList
set thisItem to item i of ItemList
--Datei zum anzeigen öffnen
tell application "Preview"
open thisItem
end tell
--Belegdaten abfragen
display dialog "Belegdatum eingeben:" & return & "(Format: YYYY-MM-DD)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
set Belegdatum_ to text returned of the result
tell application "Evernote"
activate
set ListOfTags to {}
set allTags to every tag
repeat with currentNotebook in allTags
set currentTagName to (the name of currentNotebook)
copy currentTagName to the end of ListOfTags
end repeat
set Folders_sorted to my simple_sort(ListOfTags)
set SelTag to choose from list of Folders_sorted with title "TAG Auswählen" with prompt ¬
"TAG 1 auswählen (Firma):" OK button name "OK" cancel button name "Abbrechen"
set EVTag1 to item 1 of SelTag
set Belegfirma_ to item 1 of SelTag
set ListOfTags to {}
set allTags to every tag
repeat with currentNotebook in allTags
set currentTagName to (the name of currentNotebook)
copy currentTagName to the end of ListOfTags
end repeat
set Folders_sorted to my simple_sort(ListOfTags)
set SelTag to choose from list of Folders_sorted with title "TAG Auswählen" with prompt ¬
"TAG 2 auswählen (Belegart):" OK button name "OK" cancel button name "Abbrechen"
set EVTag2 to item 1 of SelTag
set Belegart_ to item 1 of SelTag
end tell
display dialog "Bezeichnung eingeben:" & return & "(z.B. iPad)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
set Belegbezeichnung_ to text returned of the result
set Belegname_ to Belegdatum_ & "_" & EVTag1 & "_" & EVTag2 & "-" & Belegbezeichnung_
-- Datei wieder schliessen
tell application "Preview" to quit
--Datei umbenennen
set name of thisItem to Belegname_ & ".pdf"
set NeueDatei to selection
-- Einstellungen für Evernote import
set Notizbuch to "ABLAGE" -- Notizbuch
-- Nach Evernote importieren
tell application "Evernote"
create note from file NeueDatei notebook {Notizbuch} tags {EVTag1, EVTag2}
end tell
end repeat
end try
end tell
--------------------------------------------------
-- SORT SUBROUTINE
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end simple_sort
Und hier die Events aus AppleScript:
tell application "Finder"
get selection
open document file "2016-01-01_.TEST_.TEST-TEST.pdf.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk
end tell
tell application "Evernote"
path to current application
end tell
tell application "Finder"
path to resource "Evernote.icns" in bundle alias "Macintosh SSD:Applications:Evernote.app:"
display dialog "Belegdatum eingeben:
(Format: YYYY-MM-DD)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon alias "Macintosh SSD:Applications:Evernote.app:Contents:Resources:Evernote.icns"
end tell
tell application "Evernote"
activate
get every tag
get name of tag ".TESTTAG1"
get name of tag "TESTTAG2"
choose from list {".TESTTAG1", "TESTTAG2"} with title "TAG Auswählen" with prompt "TAG 2 auswählen (Belegart):" OK button name "OK" cancel button name "Abbrechen"
path to current application
end tell
tell application "Finder"
path to resource "Evernote.icns" in bundle alias "Macintosh SSD:Applications:Evernote.app:"
display dialog "Bezeichnung eingeben:
(z.B. iPad)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon alias "Macintosh SSD:Applications:Evernote.app:Contents:Resources:Evernote.icns"
end tell
tell application "Preview"
quit
end tell
tell application "Finder"
set name of document file "2016-01-01_.TEST_.TEST-TEST.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk to "2016-01-01_.TESTTAG1.TESTTAG2-TEST.pdf"
get selection
get document file "2016-01-01_.TESTTAG1.TESTTAG2-TEST.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk
end tell
Ich hoffe jemand kann mir weiterhelfen...danke schonmal
Gruß
FloZi
ich versuche gerade ein Script zu erstellen welches eine markierte Datei (Abfrage der Variablen via Dialogfenster und durch eine Abfrage der Evernote Tags) umbennent und dann in Evernote importiert.
Ich hab mir aus dem Netz diverse Code Schnipsel zusammen gesucht und durch viel lesen und probieren bin ich schon relativ weit, jetzt hängts nur leider irgendwo...
Das Script läuft bis einschl. umbennen, dannach stoppt es.
Hier das Script:
tell application "Finder"
try
set ItemList to selection
repeat with i from 1 to count of ItemList
set thisItem to item i of ItemList
--Datei zum anzeigen öffnen
tell application "Preview"
open thisItem
end tell
--Belegdaten abfragen
display dialog "Belegdatum eingeben:" & return & "(Format: YYYY-MM-DD)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
set Belegdatum_ to text returned of the result
tell application "Evernote"
activate
set ListOfTags to {}
set allTags to every tag
repeat with currentNotebook in allTags
set currentTagName to (the name of currentNotebook)
copy currentTagName to the end of ListOfTags
end repeat
set Folders_sorted to my simple_sort(ListOfTags)
set SelTag to choose from list of Folders_sorted with title "TAG Auswählen" with prompt ¬
"TAG 1 auswählen (Firma):" OK button name "OK" cancel button name "Abbrechen"
set EVTag1 to item 1 of SelTag
set Belegfirma_ to item 1 of SelTag
set ListOfTags to {}
set allTags to every tag
repeat with currentNotebook in allTags
set currentTagName to (the name of currentNotebook)
copy currentTagName to the end of ListOfTags
end repeat
set Folders_sorted to my simple_sort(ListOfTags)
set SelTag to choose from list of Folders_sorted with title "TAG Auswählen" with prompt ¬
"TAG 2 auswählen (Belegart):" OK button name "OK" cancel button name "Abbrechen"
set EVTag2 to item 1 of SelTag
set Belegart_ to item 1 of SelTag
end tell
display dialog "Bezeichnung eingeben:" & return & "(z.B. iPad)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon path to resource "Evernote.icns" in bundle (path to application "Evernote")
set Belegbezeichnung_ to text returned of the result
set Belegname_ to Belegdatum_ & "_" & EVTag1 & "_" & EVTag2 & "-" & Belegbezeichnung_
-- Datei wieder schliessen
tell application "Preview" to quit
--Datei umbenennen
set name of thisItem to Belegname_ & ".pdf"
set NeueDatei to selection
-- Einstellungen für Evernote import
set Notizbuch to "ABLAGE" -- Notizbuch
-- Nach Evernote importieren
tell application "Evernote"
create note from file NeueDatei notebook {Notizbuch} tags {EVTag1, EVTag2}
end tell
end repeat
end try
end tell
--------------------------------------------------
-- SORT SUBROUTINE
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end simple_sort
Und hier die Events aus AppleScript:
tell application "Finder"
get selection
open document file "2016-01-01_.TEST_.TEST-TEST.pdf.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk
end tell
tell application "Evernote"
path to current application
end tell
tell application "Finder"
path to resource "Evernote.icns" in bundle alias "Macintosh SSD:Applications:Evernote.app:"
display dialog "Belegdatum eingeben:
(Format: YYYY-MM-DD)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon alias "Macintosh SSD:Applications:Evernote.app:Contents:Resources:Evernote.icns"
end tell
tell application "Evernote"
activate
get every tag
get name of tag ".TESTTAG1"
get name of tag "TESTTAG2"
choose from list {".TESTTAG1", "TESTTAG2"} with title "TAG Auswählen" with prompt "TAG 2 auswählen (Belegart):" OK button name "OK" cancel button name "Abbrechen"
path to current application
end tell
tell application "Finder"
path to resource "Evernote.icns" in bundle alias "Macintosh SSD:Applications:Evernote.app:"
display dialog "Bezeichnung eingeben:
(z.B. iPad)" with title "Script by FloZi.de" default answer "" buttons {"Weiter", "Abbrechen"} default button 1 with icon alias "Macintosh SSD:Applications:Evernote.app:Contents:Resources:Evernote.icns"
end tell
tell application "Preview"
quit
end tell
tell application "Finder"
set name of document file "2016-01-01_.TEST_.TEST-TEST.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk to "2016-01-01_.TESTTAG1.TESTTAG2-TEST.pdf"
get selection
get document file "2016-01-01_.TESTTAG1.TESTTAG2-TEST.pdf" of folder "test" of folder "Desktop" of folder "FloZi" of folder "Users" of startup disk
end tell
Ich hoffe jemand kann mir weiterhelfen...danke schonmal
Gruß
FloZi