importing from a file??

Started by bowen73, May 05, 2017, 08:34:08 AM

Previous topic - Next topic

bowen73

Hi, im a newbie to linux and trying to get my head around things but cant seam to get an import working.

What im after is if i have a csv/xml/text etc document and in that i have a tag like gpsaltitude 12345 and i want to write this tag into images in a directory.  ive tried various permitations  and tried exporting the exif to a file and changing an element and re-import it but that doesnt work either. 

i get errors like x images left unchanged
no source file column
and various more.

can anyone point me in the right direction so i can create a document with the tag/tags i want and be able to import them into the exif of the images.

thanks

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bowen73

hi,  Ive just read that and its similar to other posts in the forum.

so the 'sourcefile'  HAS to contain the location to the file e.g. /home/use/pictures/image.jpg ?

can it be done where i have a tag in a csv or txt document and it looks at images in a folder and applies the tag to all them images without having to set a sourcefile in the document.

Im basically after a script where it watches a folder and when an image arrives it adds in the tag and moves the image to a new location.  but im taking a step at a time and trying to get the data in the image in the first place so the source file at the time wont be know

thanks

Phil Harvey

The SourceFile may be set to '*' to apply to all files specified on the command line.  But at this point using the -csv option becomes a bit pointless, and it is maybe easier to just specify the tags on the command line:

exiftool -gpslatitude=12.345 DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bowen73

brilliant, thanks.  i'll try that. 

I want to try it as a csv as i intend to have the info in the file change (done by another process)  and then it will just update the images accordingly. Otherwise as you say adding it in as part of the script will be better

Phil Harvey

If you want to do this from an external file, the file can take the form

-gpslatitude=12.345
-gpslongitude=34.567


and the command can be

exiftool -@ my.args DIR

where "my.args" is the name of the argfile above.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bowen73

wow thats brilliant... so if i create a text file via some external thing im yet to start and name it something like my.args instead of my.text and include my arguments it will do it for all the images in the folder?  instead of the csv option?

you sir are a genius!  times like this is shows how much i need to learn to get only slightly ok, i have a long road ahead hahaha

Phil Harvey

It doesn't matter what you name the file.  I just used "my.args" as an example, but "anything.text" works fine too.

Yes, the command will apply the tags to all writable files in folder "DIR".

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

bowen73

#8
not sure what im doing wrong...

exiftool -@ ~/Documents/scan.txt ~/Pictures

and in the scan.txt file ive placed:

-gpsaltitude=54321

but what i get is:

directories scanned
    0 image files read


but no changes to the file?

I did say i was a newbie...prob making blatant newbie mistake but i have no idea what :-s

*update*  - i changed the command to exiftool -@ ~/Documents/scan.txt ~/Pictures/test1   (test1 being my test image) and it said 1 image file was update but need to be able to update without naming the file.  is there also a way to stop it making a copy of the edited file too?

thanks - Mark

StarGeek

Do your files not have extensions?  In that case add -ext *.  Normally, exiftool will only read files with extensions it recognizes. 

To avoid making the backup files, add -overwrite_original.  To remove previously created backup files, you can use exiftool -delete_original! FileOrDir.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

bowen73

Quote from: StarGeek on May 05, 2017, 05:57:55 PM
Do your files not have extensions?  In that case add -ext *.  Normally, exiftool will only read files with extensions it recognizes. 

To avoid making the backup files, add -overwrite_original.  To remove previously created backup files, you can use exiftool -delete_original! FileOrDir.

thats perfect thank you!

i did a screen shot as my test image an even though i can open it and see thumb it didt give it an extension (the wonders of linux that im finding out!).  i renamed the file with a .jpg ext and added in the -overwrite_original and it worked perfectly.

next search is to move the file to new location once exif has been updated. :-)


StarGeek

Quote from: bowen73 on May 05, 2017, 06:46:07 PM
next search is to move the file to new location once exif has been updated. :-)

Move and update in the same command
C:\>type temp.txt
-gpsaltitude=54321
C:\>exiftool -gpsaltitude X:\!temp\Test3_xyz.jpg

C:\>exiftool -P -overwrite_original "-directory=X:\!temp\NewDirectory" -@ temp.txt X:\!temp\Test3_xyz.jpg
    1 directories created
    1 image files updated

C:\>exiftool -gpsaltitude X:\!temp\NewDirectory\Test3_xyz.jpg
GPS Altitude                    : 54321 m

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

bowen73

Quote from: StarGeek on May 05, 2017, 08:17:58 PM
Quote from: bowen73 on May 05, 2017, 06:46:07 PM
next search is to move the file to new location once exif has been updated. :-)

Move and update in the same command
C:\>type temp.txt
-gpsaltitude=54321
C:\>exiftool -gpsaltitude X:\!temp\Test3_xyz.jpg

C:\>exiftool -P -overwrite_original "-directory=X:\!temp\NewDirectory" -@ temp.txt X:\!temp\Test3_xyz.jpg
    1 directories created
    1 image files updated

C:\>exiftool -gpsaltitude X:\!temp\NewDirectory\Test3_xyz.jpg
GPS Altitude                    : 54321 m


OMG thats amazing, thank you!

i did some research last night through forum searches but wasnt quite getting the right results, but i'll definately  be giving this a go. i'll need to linux it but the commands should be the same

thanks again.

bowen73

Quote from: StarGeek on May 05, 2017, 08:17:58 PM
Quote from: bowen73 on May 05, 2017, 06:46:07 PM
next search is to move the file to new location once exif has been updated. :-)

Move and update in the same command
C:\>type temp.txt
-gpsaltitude=54321
C:\>exiftool -gpsaltitude X:\!temp\Test3_xyz.jpg

C:\>exiftool -P -overwrite_original "-directory=X:\!temp\NewDirectory" -@ temp.txt X:\!temp\Test3_xyz.jpg
    1 directories created
    1 image files updated

C:\>exiftool -gpsaltitude X:\!temp\NewDirectory\Test3_xyz.jpg
GPS Altitude                    : 54321 m


going down the -directory route, ive seen where you can use exif tag to create a folder.

going back to the altitude....as im using that to enter a code....  if wanted to created a directory for the tag (.eg 54321)  if would be -directory<gpsaltitude  but if i wanted to place that directory in /home/images/54321  then how would i do this.  the -directory<gpsaltitude would give /home/5321  but cant get it to do /home/images/54321 

also how would i get it to drop the 'm' when it creates the directory to as the -directory<gpsaltitude gives me /home/54321 m

thanks

StarGeek

You've already figured out that to copy a tag you have to use Tag Copy (< or >) instead of Tag Assignment (=).  Since you want to add some more text in addition to the tag, you have to put a dollar sign in front of the tag name.  Also, since you're using a dollar sign with the tag an using linux, you'll have to use single quotes instead of double quotes (see the .sig on any of Phil's posts).

To remove the "(space)m" at the end, in this case you can just put a hash mark at the end of the tag name.  This is the same as the -n option.

Your command would end up something like:
exiftool -overwrite_original '-directory</home/images/$gpsaltitude#' -@ temp.txt FileOrDir
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).