Erstelldatum ändern

Hallo Leute,

Ich bin neu hier. Ich nutze DTOP und bin dabei mein Leben auf ein Papierloses so weit als möglich zu Organisieren.
Ich nutze eine ScanSnap IX500 um meine Dokumente zu Scannen und dann in DT zu Importieren.
Nun würde ich gerne folgendes machen bzw. machen lassen.

Ich Scanne ein Dokument in denn HotFolder. dort wird dann erkannt das es sich um ein PDF handelt, es wird in den Globalen Eingang kopiert, OCR ausgeführt und die alte Datei gelöscht.
Was mir hierbei noch fehlt, ist die Möglichkeit, das ein Datum aus dem Brief (Dokument ausgelesen wird, und als Erstelldatum der Datei Gesetzt wird.

Wie kann ich dieses Verwirklichen.
Derzeit nutze ich ein Script, das den markierten Bereich als Erstelldatum ändert. aber bei 30.000 Dokumenten wird dies eine mühevolle Arbeit.

Vielen Dank für eure Hilfe vorab.

Hier noch das Script das ich derzeit verwende:

set theText to get_date_String()
if theText is missing value or theText is “” then
set theText to “”
set theResult to display dialog theText buttons {“Cancel”, “Ok”} default button 2 default answer “” with icon 1
set theText to text returned of theResult
end if

set theText to my replaceText(theText, “ä”, “ä”)
set theDate to date theText
set_creation_date_to(theDate)

on get_date_String()
tell application “DEVONthink Pro”
try
if not (exists think window 1) then error “No window is open.”
if not (exists content record) then error “Please open a document.”
return selected text of think window 1 as string
on error error_message number error_number
if the error_number is not -128 then display alert “DEVONthink Pro” message error_message as warning
end try
end tell
end get_date_String

on set_creation_date_to(d)
tell application “DEVONthink Pro”
try
set theSelection to the selection
repeat with theRecord in theSelection
set creation date of theRecord to d
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert “DEVONthink Pro” message error_message as warning
end try
end tell
end set_creation_date_to

on replaceText(theString, find, replace)
if theString contains find then
local od
set od to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set theString to text items of theString

	set text item delimiters of AppleScript to replace
	set theString to "" & theString
	set text item delimiters of AppleScript to od
end if
return theString

end replaceText

Hoffe es gibt Hilfe für mein anliegen.

Grüße
Nico

Im Augenblick ist das wahrscheinlich nur mit externen Tools wie Hazel zuverlässig möglich, v.a. wenn das Datum in den unterschiedlichsten Formaten vorkommt.

Eine zukünftige Version wird dies aber unterstützen, d.h. sowohl dieses Skript unnötig machen als auch die Automatisierung vereinfachen.

Danke für die Antwort!!!

Könnte man aus den Kommentaren ein Datum nehmen, um es beim “Import & Delete” Script auszulesen, und als Erstelldatum zu setzen?

Und wenn ja, wie würde das Script aussehen?

Grüße
Nico

Wie sieht denn so ein Kommentar konkret aus?

Hallo,

denn Kommentar könnte man vom Datumsformat ja setzen wie man möchte: Gefallen würde mir natürlich dieses Format.

TT.MM.JJJJ

und die Uhrzeit könnte Standardmäßig immer 00:00 anzeigen, somit wäre man auch sicher das die Änderung durchgeführt wurde.

Grüße
Nico

Sofern es sich dabei um den Spotlight/Finder-Kommentar handelt, würde das Skript so aussehen. Zumindest auf deutschen Systemen ist das Format DD.MM.YYYY.


on adding folder items to this_folder after receiving added_items
	try
		if (count of added_items) is greater than 0 then
			tell application id "DNtp" to launch
			repeat with theItem in added_items
				try
					set thePath to theItem as text
					if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
						tell application id "DNtp"
							set theRecord to import thePath to incoming group
							if exists theRecord then
								tell application "Finder"
									set theComment to comment of theItem
									delete theItem
								end tell
								if theComment contains "." then
									set theDate to my getDate(theComment)
									set creation date of theRecord to theDate
								end if
							end if
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

on getDate(theStr)
	return date (theStr)
end getDate

Hallo Herr Grunenberg,

Danke für Ihre Antwort. Habe das Script kopiert, leider kommt es zu einer Fehlermeldung. Habe das Foto angehängt, hoffe Sie können mir weiterhelfen.

Grüße
Nico

Aus welchem Browser haben Sie den Code kopiert? Mit Safari scheint es hier zu funktionieren.

ja aus Safari habe ich den Code kopiert.

Danke für die Hilfe.

Grüße
Nico

Ich konnte das Problem lösen,
Das Script habe ich nochmal angehängt.

Mein Workflow sieht nun wie folgt aus:
Scan mit ScanSnap IX500 in einen Ordner “Scaneingang” als PDF mit OCR.
Dann wird das Dokument durch diverse Hazel Regeln geschickt und benannte.
Danach wird nach dem Datum gesucht, und in die Kommentare geschrieben.
Danach wird die Datei in eine HotFolder geschoben, von wo sie Importiert, das in den Kommentare stehende Datum als Erstellungsdatum gesetzt, und die Datei in dem HotFolder gelöscht.

Solange meine Hazel Regeln passen, funktioniert es perfekt. Wenn keine Regel zutrifft, wird die Datei in den Ordner “Manuel Processing” geschoben, und wird dann von mir geprüft, Regeln erweitert, oder eben Manuel in DT eingefügt.

Vielen Dank für die Hilfe.

Grüße
Nico

on adding folder items to this_folder after receiving added_items
	try
		if (count of added_items) is greater than 0 then
			tell application id "DNtp" to launch
			repeat with theItem in added_items
				try
					set thePath to theItem as text
					if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
						tell application id "DNtp"
							set theRecord to «event DTpacd01» thePath given «class DTto»:«class DTig»
							
							if exists theRecord then
								tell application "Finder"
									set theComment to comment of theItem
									delete theItem
								end tell
								
								if theComment contains "." then
									set theDate to my getDate(theComment)
									set «class DTcr» of theRecord to theDate
								end if
							end if
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

on getDate(theStr)
	return date (theStr)
end getDate