Check if Exif field exists, and add data.

When I take images from my camera, it contains the Author field as Photographed_by_me, However I also use Helicon Focus, after layering the images all Exif info is lost.

Due to the way my workflow operates, I would like to make a script that checks if this Exif field exists using exifTool http://www.sno.phy.queensu.ca/~phil/exiftool/. If the Author field contains something then move it to Folder B. else add the author as “Photographed_by_me” then move this file to folder B.

In Photoshop it shows as “Author”, under the description tag, but in the coding I think its “Creator”

I hope someone can help me with this?

Many Thanks

Matt

I’ve started to look at the script, I think I need something like this? But I don’t know how I should write the varible in the shell script.

tell application "Finder"
          set this_folder to folder "Hal 9000:Users:matthew:Pictures:Helicon" as alias
          set theHotFolder to folder "HotFolder" as alias
          set itemList to every file in this_folder
end tell
 
repeat with i from 1 to count of itemList
          set newFile to item i of itemList
 
 
         
          set theCreator to do shell script "/usr/bin/exiftool -ownername " & (quoted form of newFile)
 
  --set returned result of the command above to theCreator
 
  --if theCreator is equal to "" (nothing) then
  --do shell script "/usr/bin/exiftool -ownername="Photographed_by_me" " & (itemList)"
  --then move newFile to theHotFolder
  --else move newFile to theHotFolder
 
end repeat

basic usage:

			do shell script "exiftool -IFD0:ImageDescription=" & quoted form of ganzerString & " -IFD0:Artist=" & quoted form of fotograf & " -IFD0:Copyright=" & quoted form of copyright & " -IPTC:Caption-Abstract=" & quoted form of ganzerString & " -IPTC:By-line=" & quoted form of fotograf & " -IPTC:Writer-Editor=" & quoted form of fotograf & " -IPTC:By-LineTitle='Bildjournalist' -IPTC:Credit=" & quoted form of "Credit" & "  -IPTC:ObjectName=" & quoted form of bildname & " -IPTC:City='Aachen'  -IPTC:Province-State='Nordrhein-Westfalen' -IPTC:Country-PrimaryLocationName='DEU Deutschland' -IPTC:Keywords=" & quoted form of stichwort & " -IPTC:CopyrightNotice=" & quoted form of copyright & " -XMP-dc:Description=" & quoted form of ganzerString & " -XMP-dc:Creator=" & quoted form of fotograf & " -XMP-dc:Rights=" & quoted form of copyright & " -XMP-dc:Title=" & quoted form of bildname & " -XMP-dc:Subject=" & quoted form of stichwort & " -XMP-photoshop:AuthorsPosition=" & quoted form of "Bildjournalist" & " -XMP-photoshop:CaptionWriter=" & quoted form of fotograf & " -XMP-photoshop:City='Aachen' -XMP-photoshop:State='Nordrheinwestfalen' -XMP-photoshop:Country=" & quoted form of "DEU Deutschland" & " -XMP-photoshop:Credit=" & quoted form of "Credit" & " -XMP-photoshop:Source=" & quoted form of "Source" & " -XMP-xmpRights:WebStatement=" & quoted form of webadresse & " -XMP-iptcCore:CreatorWorkTelephone=" & quoted form of telnummer & " -XMP-iptcCore:CreatorWorkEmail=" & quoted form of mail & " -XMP-iptcCore:CreatorCity='Aachen' -XMP-iptcCore:Address=" & quoted form of "eine strasse" & " -Photoshop:URL=" & quoted form of webadresse & " " & quoted form of POSIX path of pathToFile

So far…

tell application "Finder"
	set this_folder to (alias ((path to pictures folder as text) & "HELICON"))
	set itemList to every file in this_folder
end tell


repeat with i from 1 to count of itemList
	set newFile to item i of itemList as alias
	tell application "System Events"
		set iFile to properties of newFile
		set theFile to (POSIX path of iFile)
		
	end tell
	log theFile
	set theCreator to do shell script "/usr/bin/exiftool -ownername " & theFile
	log theCreator
	
end repeat

I might actually be getting there! Just need to look to see how it reacts in the real world

tell application "Finder"
	set this_folder to (alias ((path to pictures folder as text) & "HELICON"))
	set itemList to every file in this_folder
	set theHotFolder to the folder "HotFolder"
end tell


repeat with i from 1 to count of itemList
	set newFile to item i of itemList as alias
	tell application "System Events"
		set iFile to properties of newFile
		set theFile to (POSIX path of iFile)
		
	end tell
	log theFile
	set theCreator to do shell script "/usr/bin/exiftool -ownername " & theFile
	if theCreator is equal to "" then
		display dialog "Empty"
		do shell script "/usr/bin/exiftool -ownername='Photographed_by_me' " & theFile
		
	else
		display dialog theCreator
	end if
	
end repeat

OK.>>>> Just need to move it the bit I thought this was the easy bit, any ideas please?

tell application "Finder"
	set this_folder to (alias ((path to pictures folder as text) & "HELICON"))
	set itemList to every file in this_folder
	set theHotFolder to folder "Hal 9000:Users:matthew:Desktop:HotFolder"
	
end tell


repeat with i from 1 to count of itemList
	set newFile to item i of itemList as alias
	tell application "System Events"
		set iFile to properties of newFile
		set theFile to (POSIX path of iFile)
		
	end tell
	log theFile
	set theCreator to do shell script "/usr/bin/exiftool -ownername " & theFile
	if theCreator is equal to "" then
		do shell script "/usr/bin/exiftool -overwrite_original -ownername='Photographed_by_me' " & theFile
		move newFile to theHotFolder
	else
		move newFile to theHotFolder
	end if
	
end repeat

tell application “Finder”
move newFile to theHotFolder
end tell


Appears to be working ok now, I welcome improvements to the script.

instead of


set newFile to item i of itemList as alias
tell application "System Events"
	set iFile to properties of newFile
	set theFile to (POSIX path of iFile)
end tell


you can write


set newFile to item i of itemList as alias
set theFile to POSIX path of newFile -- class alias has a property POSIX path

and quote always paths in shell scripts

that seams to work I knew it was messy like that

Many Thanks

I knew that was messy but couldn’t figure it out.

this is how it looks now
Thanks Matt

tell application "Finder"
	set this_folder to (alias ((path to pictures folder as text) & "HELICON"))
	set itemList to every file in this_folder
	set theHotFolder to folder "Hal 9000:Users:matthew:Desktop:HotFolder"
	
end tell


repeat with i from 1 to count of itemList
	set newFile to item i of itemList as alias
	set theFile to POSIX path of newFile
	set theCreator to do shell script "/usr/bin/exiftool -ownername " & theFile
	if theCreator is equal to "" then
		do shell script "/usr/bin/exiftool -overwrite_original -ownername='Photographed_by_Me' " & theFile
		tell application "Finder"
			delay 5 -- time here is needed to rewrite the file or ot won't move
			move newFile to theHotFolder
		end tell
	else
		tell application "Finder"
			move newFile to theHotFolder
		end tell
	end if
	
end repeat


.
 set theFile to quoted form of POSIX path of newFile
.

The reason is you will run into problems if the path contains space characters

Yes you a right I did change that as it wouldn’t pick up on some file names with spaces.

Many Thanks

Matt