AutoHotkey: Copy and Paste of Exif via ExifTools

From TotalcmdWiki
Jump to navigation Jump to search

Now I started arranging my photographs: many of panoramas does not have any exif. Thus I have just created a simple tool which makes "copy" and "paste" of exif data among the files. I am not very familiar well with both AutoHotKey and exiftool thus this script is VERY primitive. But it works. It contains 2 functions: copies EXIF from the file under cursor into temporary file (Alt+Win+C) and pastes EXIF without orientation into the file under cursor (Alt+Win+V). The latter is done by copying the file into temporary folder (Correct in script!), then in copies EXIF into temporary file (must be created beforehand). The former - is copying the file into the temporary folder (Correct again), copies exif data into the file (Original file is retained in the temp folder - just in case. Delete them manually) and copies the filed backwards.

It requires several things:

;	Requirements!
;	HotKey must be set in TC:  Ctrl + [ = cm_CopyNamesToClip
;	HotKey must be set in TC:  Ctrl + p = cm_CopyFullNamesToClip
;	tempfolder must exist. It should not contain some characters like spaces, etc as ExifTool does not always like it
;	tempfile must be created beforehand (It is better to use some small real jpg file). It will be overwritten during operation
;      ExifTool must be in the temp folder

IfWinActive, ahk_class TTOTAL_CMD
{
	#!C::
	tempFolder := "G:\temp\"	
	; That is temporary folder. ExifTools must be here. Folder path MUST NOT contain spaces and dashed - exiftools will not work
	FileName := "ExifTemp.jpg"
	; All Tags are copied from the file info FileName temporary file (It must be created beforehand !!!)

	; First, file under cursor is sent to temp folser
	Send ^[		;filename to clipboard 			TC shortcut
	File=%tempFolder%%clipboard%
	Send ^p		;filename with path to clipboard 	TC shortcut
	Destination=%clipboard%

	RunWait cmd /C copy /Y %Destination% %tempFolder%
       
       RunWait %tempFolder%exiftool -overwrite_original -all= %tempFolder%%FileName%
    
	RunWait %tempFolder%exiftool -overwrite_original -TagsFromFile %File% -exif:all %tempFolder%%FileName%
;	clipboard=%tempFolder%exiftool -overwrite_original -TagsFromFile %File% -exif:all %tempFolder%%FileName%
	
	Return
} 
Return


IfWinActive, ahk_class TTOTAL_CMD
{ 
	#!V::
	; All Tags are copied from the file info FileName temporary file (It must be created beforehand !!!)
	tempFolder := "G:\temp\"	
	; That is temporary folder. ExifTools must be here. Folder path MUST NOT contain spaces and dashed - exiftools will not work
	FileName := "ExifTemp.jpg"
	; All Tags are copied from the file info FileName temporary file (It must be created beforehand !!!)


	Send ^[		;filename to clipboard
	File=%clipboard%
	Send ^p		;filename with path to clipboard 	TC shortcut
	Destination=%clipboard%

	RunWait cmd /C copy /Y %Destination% %tempFolder% 

	RunWait %tempFolder%exiftool.exe -TagsFromFile %tempFolder%%FileName% -exif:all -Orientation= %tempFolder%%File%
; 	clipboard=%tempFolder%exiftool.exe -overwrite_original -TagsFromFile %tempFolder%%FileName% %tempFolder%%File%
	
	RunWait cmd /C copy /Y %tempFolder%%File% %Destination%

	Return
} 
Return

This is a side-script (Alt+Win+N) removes GPS data from the file under cursor

IfWinActive, ahk_class TTOTAL_CMD	;removing GPS data from the file
{
	#!N::
	tempFolder := "G:\temp\"	
	; That is temporary folder. ExifTools must be here. Folder pash MUST NOT contain spaces and dashed - exiftools will not work
	FileName := "ExifTemp.jpg"
	; All Tags are copied from the file info FileName temporary file (It must be created beforehand !!!)

	; First, file under cursor is sent to temp folser
	Send ^[		;filename to clipboard 			TC shortcut
	File=%tempFolder%%clipboard%
	Send ^p		;filename with pathto clipboard 	TC shortcut
	Destination=%clipboard%

	RunWait cmd /C copy /Y %Destination% %tempFolder%
	
	RunWait %tempFolder%exiftool -overwrite_original -GPS:all= %File%

	clipboard=%tempFolder%exiftool -overwrite_original -GPS:all= %File%

	RunWait cmd /C copy /Y %File% %Destination%
	
	Return
}
Return


Back to AutoHotkey