Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

#255822 2-Sep-2019 08:01
Send private message

In the past I used a program called JAlbum to create static web galleries, which is fine for my use. The jalbum website is down, not sure if it's an isolated failure or if it's gone.

 

Later versions of JAlbum put comments into jpeg image metadata - doesn't seem to do it for mp4 files. When JAlbum was new image description went into a file called comments.properties. I'd like to copy these comments from the text file to the jpeg "ImageDescription" field. Does anyone have any suggestions how to do this? File format is something like.

 

filename1.jpg=Here's a family photo!

 

filename2.jpeg=Little Billy catches a fish

 

 

 

I could write a bit of Java to do it, but that'd take hours as I'd need to find a jpeg library. Any other suggestions how to do this more quickly / easily?


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
 1 | 2
SirHumphreyAppleby
2938 posts

Uber Geek
+1 received by user: 1860


  #2309222 2-Sep-2019 08:16
Send private message

ExifTool and a simple command line?

 

 

for /f "tokens=1,* delims==" %a in (comments.properties) do ExifTool.exe %a -ImageDescription="%b"

 

 

Replace % with %% if used in a batch file.

 

EDIT: Mixed up file name with property. Fixed now.




timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2309240 2-Sep-2019 09:23
Send private message

Thanks @SirHumphreyAppleby that's the kind of thing I was looking for :) Which command line is that - dos / bash / other - looks like dos?


SirHumphreyAppleby
2938 posts

Uber Geek
+1 received by user: 1860


  #2309246 2-Sep-2019 09:28
Send private message

timmmay:

 

Thanks @SirHumphreyAppleby that's the kind of thing I was looking for :) Which command line is that - dos / bash / other - looks like dos?

 

 

Windows Command Prompt.




timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2309679 2-Sep-2019 20:54
Send private message

@SirHumphreyAppleby I just got a change to try it - almost perfect thanks! I just had to add one set of speech marks to cope with filenames with a space in them. The command line is

 

 

 

for /f "tokens=1,* delims==" %a in (comments.properties) do ExifTool.exe "%a" -ImageDescription="%b"r:

 

 

 

For bonus points - can this be made recursive and look at the comments.properties file in each folder? I see the for command can be made recursive with "for /R", but it has a whole different set of options that don't seem compatible with "for /f".


Oblivian
7345 posts

Uber Geek
+1 received by user: 2117

ID Verified

  #2309692 2-Sep-2019 21:15
Send private message

If you want a bit more manual work during processing and use LR, there's a stashed method to sync IPCT in the import tab

 

https://helpx.adobe.com/nz/lightroom-classic/help/metadata-basics-actions.html#add_and_edit_iptc_metadata 

 

 

 

-r is recursive for exiftool, but you would need to mod the initial command a bit

 

https://sno.phy.queensu.ca/~phil/exiftool/mistakes.html 

 

     

  1. The -r option (to recursively process sub-directories) is only effective when a directory name is specified, so it doesn't work when "*.*" is specified (unless the first-level directories have a "." in the name, as mentioned in point b above)

 

Some tips there to do it as a line vs get a batch to do it too.


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2309707 2-Sep-2019 21:51
Send private message

Thanks for the ideas. I don't like / use Lightroom. I've used bridge successfully for many years, tried LR but found the UI and workflow really slow.

 
 
 

Shop now on AliExpress (affiliate link).
SirHumphreyAppleby
2938 posts

Uber Geek
+1 received by user: 1860


  #2309756 3-Sep-2019 07:16
Send private message

timmmay:

 

For bonus points - can this be made recursive and look at the comments.properties file in each folder? I see the for command can be made recursive with "for /R", but it has a whole different set of options that don't seem compatible with "for /f".

 

 

I'd use a batch file for this. Make sure ExifTool is in your path (or change the command to the full path).

 

 

for /f %%a in ('dir /b /s /ad') do (
 pushd "%%a"
 if exist comments.properties (
  for /f "tokens=1,* delims==" %%b in (comments.properties) do ExifTool.exe "%%b" -ImageDescription="%%c"
 )
 popd
)

 


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2309781 3-Sep-2019 09:04
Send private message

Thanks, I'll give that a shot tonight or when I next get time :)


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2311834 6-Sep-2019 15:37
Send private message

I just got to test this. Thanks again @SirHumphreyAppleby it works perfectly, you're some kind of a DOS coding genius!


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2311838 6-Sep-2019 15:43
Send private message

Sign. I then realise that I have another album with a different metadata type. In this one the format is below. Do you think this will work with the batch file you gave me or does it need tweaking?

 

 

 

filename.jpg.description=Description

 

 


SirHumphreyAppleby
2938 posts

Uber Geek
+1 received by user: 1860


  #2311847 6-Sep-2019 16:08
Send private message

timmmay:

 

Sign. I then realise that I have another album with a different metadata type. In this one the format is below. Do you think this will work with the batch file you gave me or does it need tweaking?

 

filename.jpg.description=Description

 

 

Let's try that again. Had to enter a capcha to post and my reply didn't show up (@freitasm).

 

The script won't quite work as is as it treats everything before the = as the file name. It is necessary to remove .description from the file name. Something like the following (untested, sorry), should do the job...

 

 

setlocal enabledelayedexpansion
for /f %%a in ('dir /b /s /ad') do (
 pushd "%%a"
 if exist comments.properties (
  for /f "tokens=1,* delims==" %%b in (comments.properties) do (
   set fname=%%b
   ExifTool.exe "!fname:.description=!" -ImageDescription="%%c"
  )
 )
 popd
)

 


 
 
 

Shop now on AliExpress (affiliate link).
timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2311984 6-Sep-2019 21:13
Send private message

The console said "error" a lot, but a spot check suggests it's worked as well. Thanks again! I'll have a better look at the errors later and post if it's not quite worked.

 

If we meet at a Geekzone event remind me I owe you a couple of beers :)


SirHumphreyAppleby
2938 posts

Uber Geek
+1 received by user: 1860


  #2312497 7-Sep-2019 20:16
Send private message

timmmay:

 

The console said "error" a lot, but a spot check suggests it's worked as well. Thanks again! I'll have a better look at the errors later and post if it's not quite worked.

 

If we meet at a Geekzone event remind me I owe you a couple of beers :)

 

 

I gave the script a quick test this evening and the basic parsing appears to be correct. It should work with both file formats.

 

At a guess, I would say the errors are most likely from ExifTool. If ExifTool weren't in the path, you'd see errors, but it would obviously not work. The script checks for the file before trying to use it, and only tries to pushd in to directories. Everything is just built-in commands that will work with the default Windows cmd.exe configuration.

 

Happy to look at the errors and assist were I can. Beer won't be necessary.


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2312533 7-Sep-2019 21:09
Send private message

Thanks for that, I appreciate it. I'll have a proper go when I have a bit of free time - a rare thing with a toddler.


timmmay

20858 posts

Uber Geek
+1 received by user: 5350

Trusted
Lifetime subscriber

  #2736013 28-Jun-2021 19:39
Send private message

@SirHumphreyAppleby after 18 months delay I finally had a crack at this and your script worked perfectly. Thanks again :)


 1 | 2
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.