little_pixel
Aktives Mitglied
Thread Starter
- Registriert
- 06.06.2006
- Beiträge
- 4.718
- Reaktionspunkte
- 1.685
Hallo zusammen,
früher sehr viel, mittlerweile sehr selten, habe ich immer gerne in AppleScript geschrieben.
Hier ein kleines Skript für die Anwender, die vor der gleichen Aufgabe stehen.
Ausgangssituation:
Gerne verwende ich die Mini-Drohne DJI Neo für autonome Aufnahmen.
Bedauerlicherweise speichert DJI immer noch nicht die GPS-Daten in den Metadaten der Videos.
Aufnahmen erstelle ich meist an einem Ort, der mir klar gut gefällt, und ich auch mit dem iPhone ein paar Schnappschüsse getätigt habe.
D.h. die DJI-Videos haben keine Ortsinformationen, aber die umliegenden iPhone Fotos/Videos schon.
Das Setzen der Ortsinformationen innerhalb der Fotos.app auf dem Mac emppfinde ich in dem Infofenster bei einem Foto/Video als sehr mühsam.
Hier müßte Apple mal dringend nachbessern.
Idee:
Von einem iPhone Foto/Video, das örtlich zugehörig zu dem DJI-Video ist, die Ortsinformationen rüber kopieren.
Also im Prinzip wie eine Pipette die Ortsinformation aufsaugt und auf andere Videos/Fotos drauf träufeln.
Umsetzung und Anwendung:
# 1
Ein Element in der Fotos.app markieren/auswählen. Skript starten.
# 2
Das Skript prüft, ob ein einzelnes Element (Video, Foto etc.) in der Fotos.app markiert ist und speichert die GPS-Daten zwischen.
# 3
In Folge kommt ein Dialog, der zur einer Auswahl von Elementen (eins oder mehrere) auffordert, auf die die GPS-Daten übertragen werden sollen.
# 4.1
Ist die Quelle und Ziel identisch, dann fordert der Dialog endlos zur neuen Auswahl auf.
Mit dem Knopf zum Abbrechen kann das Skript aber jeder Zeit beendet werden.
# 4.2
Ist das Ziel, Einzelelement oder mehrere, ohne Ortsinformationen, dann werden die GPS-Daten direkt übertragen.
# 4.3
Ist das Ziel ein einzelnes Element und hat bereits eine Ortsinformation, dann muss das Überschreiben mit einem Dialog bestätigt werden.
# 4.3
Ist das Ziel eine Vielzahl von Elementen, dann muss, wenn ein oder mehrere Elemente Ortsinformationen haben, das Überschreiben aktiv bestätigt werden.
# 4.4
Ist das Ziel eine Vielzahl von Elementen und beinhaltet die Quelle, dann wird die Quelle zum "Neuschreiben" ignoriert.
Ich hoffe, dass das Skript jemandem hilft …
Viele Grüße
PS: Wer Fehler im Skript findet bitte melden. Danke.
früher sehr viel, mittlerweile sehr selten, habe ich immer gerne in AppleScript geschrieben.
Hier ein kleines Skript für die Anwender, die vor der gleichen Aufgabe stehen.
Ausgangssituation:
Gerne verwende ich die Mini-Drohne DJI Neo für autonome Aufnahmen.
Bedauerlicherweise speichert DJI immer noch nicht die GPS-Daten in den Metadaten der Videos.
Aufnahmen erstelle ich meist an einem Ort, der mir klar gut gefällt, und ich auch mit dem iPhone ein paar Schnappschüsse getätigt habe.
D.h. die DJI-Videos haben keine Ortsinformationen, aber die umliegenden iPhone Fotos/Videos schon.
Das Setzen der Ortsinformationen innerhalb der Fotos.app auf dem Mac emppfinde ich in dem Infofenster bei einem Foto/Video als sehr mühsam.
Hier müßte Apple mal dringend nachbessern.
Idee:
Von einem iPhone Foto/Video, das örtlich zugehörig zu dem DJI-Video ist, die Ortsinformationen rüber kopieren.
Also im Prinzip wie eine Pipette die Ortsinformation aufsaugt und auf andere Videos/Fotos drauf träufeln.
Umsetzung und Anwendung:
# 1
Ein Element in der Fotos.app markieren/auswählen. Skript starten.
# 2
Das Skript prüft, ob ein einzelnes Element (Video, Foto etc.) in der Fotos.app markiert ist und speichert die GPS-Daten zwischen.
# 3
In Folge kommt ein Dialog, der zur einer Auswahl von Elementen (eins oder mehrere) auffordert, auf die die GPS-Daten übertragen werden sollen.
# 4.1
Ist die Quelle und Ziel identisch, dann fordert der Dialog endlos zur neuen Auswahl auf.
Mit dem Knopf zum Abbrechen kann das Skript aber jeder Zeit beendet werden.
# 4.2
Ist das Ziel, Einzelelement oder mehrere, ohne Ortsinformationen, dann werden die GPS-Daten direkt übertragen.
# 4.3
Ist das Ziel ein einzelnes Element und hat bereits eine Ortsinformation, dann muss das Überschreiben mit einem Dialog bestätigt werden.
# 4.3
Ist das Ziel eine Vielzahl von Elementen, dann muss, wenn ein oder mehrere Elemente Ortsinformationen haben, das Überschreiben aktiv bestätigt werden.
# 4.4
Ist das Ziel eine Vielzahl von Elementen und beinhaltet die Quelle, dann wird die Quelle zum "Neuschreiben" ignoriert.
Ich hoffe, dass das Skript jemandem hilft …
Viele Grüße
PS: Wer Fehler im Skript findet bitte melden. Danke.
AppleScript:
property pMainTitle : "Ortsangabe übertragen"
tell application "Photos"
set theSelection to selection
if ((count of theSelection) is not 1) then
return false
end if
set theSourceItem to first item of theSelection
set theSourceItemID to id of theSourceItem
if (length of theSourceItemID < 1) then
return false
end if
set theSourceItemLocation to location of theSourceItem
if (my isValidLocation(theSourceItemLocation) is not true) then
return false
end if
if (my showNextSelectionAlert() is not true) then
return false
end if
set theSelection to selection
repeat
if ((count of theSelection) is 1) then
set theTargetItemID to id of first item of theSelection
if (length of theTargetItemID > 0) then
if theTargetItemID is not equal to theSourceItemID then
exit repeat
end if
end if
if (my showNextSelectionAlert() is not true) then
return false
end if
set theSelection to selection
else if ((count of theSelection) > 1) then
exit repeat
else
if (my showNextSelectionAlert() is not true) then
exit repeat
end if
set theSelection to selection
end if
end repeat
set theSelectionCount to count of theSelection
if (theSelectionCount < 1) then
return false
end if
set theTargetLocationCount to 0
repeat with nTargetItem in theSelection
if (my isValidLocation(location of nTargetItem) is true) then
set theTargetLocationCount to theTargetLocationCount + 1
end if
end repeat
if (theSelectionCount is 1) then
if (theTargetLocationCount > 0) then
tell me
set theAlert to display alert pMainTitle message "Das Zielelement hat bereits eine Ortsangabe. Möchtest Du diese ersetzen?" buttons {"Nein", "Ja"} default button 1 as critical
if (button returned of theAlert is not equal to "Ja") then
return false
end if
end tell
end if
else if (theSelectionCount > 1) then
if (theTargetLocationCount > 0) then
tell me
set theAlert to display alert pMainTitle message (theSelectionCount & " von " & theTargetLocationCount & " ausgewählte Elemente haben bereits Ortsangaben. Möchtest Du diese ersetzen?" as text) buttons {"Nein", "Ja"} default button 1 as critical
if (button returned of theAlert is not equal to "Ja") then
return false
end if
end tell
else
tell me
set theAlert to display alert pMainTitle message "Möchtest Du die gleiche Ortsangabe wirklich auf mehrere Elemente übertragen?" buttons {"Nein", "Ja"} default button 1 as critical
if (button returned of theAlert is not equal to "Ja") then
return false
end if
end tell
end if
else
return false
end if
set theTargetLocationCount to 0
repeat with nTargetItem in theSelection
set nTargetItemID to id of nTargetItem
if nTargetItemID is not equal to theSourceItemID then
set location of nTargetItem to theSourceItemLocation
set theTargetLocationCount to theTargetLocationCount + 1
end if
end repeat
tell me
display alert pMainTitle message "Die Ortsangaben wurde bei " & return & theSelectionCount & " von " & theTargetLocationCount & " Elementen neu gesetzt."
end tell
return true
end tell
on isValidLocation(aLocation)
if ((count of aLocation) is not 2) then
return false
end if
if (first item of aLocation is missing value) then
return false
end if
if (last item of aLocation is missing value) then
return false
end if
return true
end isValidLocation
on showNextSelectionAlert()
tell me
activate
set theAlert to display alert pMainTitle message "Wähle jetzt in der Fotos.app die Elemente aus, auf die die Ortsangabe kopiert werden soll." buttons {"Abbrechen", "Ok"} default button 1 as critical
if (button returned of theAlert is equal to "OK") then
return true
end if
end tell
return false
end showNextSelectionAlert
