Write containing folder name to TAG

Started by srb0501w, January 01, 2024, 02:25:18 PM

Previous topic - Next topic

srb0501w

Hello,
I am a couple days into exiftool and am trying to find a simple way to set the folder or sub-directory to the album tag of files recursively. The older topic on putting a directory into an event tag was close, but "-album<directory" is putting the entire filepath into the tag instead of the folder containing the files.

I was hoping that there would be some way to use the "%-1:D" discussed in the -w command in the Application Documentation, but, perhaps obviously, I guess that's only for writing outputs to a file.

I found two more (relatively) recent topics that were also about folder names to tags, and was able to experiment to get something working.
https://exiftool.org/forum/index.php?topic=7962.0
https://exiftool.org/forum/index.php?topic=6944.0

I have no real knowledge of Perl, but by changing the number for [-2] in the '-album<${FilePath;$_=(split m(/),$_)[-2]}', I was able to target the folder containing the files. All the files are the name number of directories down or I assume this wouldn't work. I can't find the exact topic I copied it from. I don't fully understand what is happening in this command. I can see it's using the Advanced formatting feature. And, as you said in one of the topics, I think this is parsing the filename into an array, broken up by "/"s, and then using the array cell two levels down from the top as the eventual album tag.

Is there a better or simpler way to do this besides using Perl scripts? I'm sshing into a Synology and am running ExifTool from its install folder. I wasn't ever able to get the program to be called globally, which is a whole separate issue that I will try to run down later. I'm sure that is also contributing to my directory naming issues.

I really appreciate this tool, it's been an amazing find!

StarGeek

Quote from: srb0501w on January 01, 2024, 02:25:18 PMI was hoping that there would be some way to use the "%-1:D" discussed in the -w command in the Application Documentation, but, perhaps obviously, I guess that's only for writing outputs to a file.

That is correct.  It's not a tag so it can't be copied into a tag. There are only a few options which will use this feature.

QuoteI think this is parsing the filename into an array, broken up by "/"s, and then using the array cell two levels down from the top as the eventual album tag.

That is absolutely correct.

QuoteIs there a better or simpler way to do this besides using Perl scripts?

One way or another, it will require some Perl. The above command could be changed into a Regular Expressions (RegEx) substitution to remove the unwanted parts of the directory, but it would still be along these lines using the Advance formatting.

The other option would be to create a User Defined tag.  That would hide all the Perl in a config file, but the config file would always have to be called, either directly with the -Config option or by including it in the .ExifTool_config file which exiftool reads upon starting.

QuoteI'm sshing into a Synology and am running ExifTool from its install folder. I wasn't ever able to get the program to be called globally, which is a whole separate issue that I will try to run down later. I'm sure that is also contributing to my directory naming issues.

You will want to look into including the exiftool directory as part of the system's PATH environmental variable.  A Google search such as this should help
https://www.google.com/search?q=linux+permanently+add+to+path
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

srb0501w

Thanks for the insight on the commands! I guess I will look up Perl if I need to customize this command more. I have a little more experience with RegEx, so I may start there instead.

Unfortunately, I have already done a fair amount of google research on DSM PATH variables without much success. Synology is nice in many ways, but I have found is often lacking in others. I will probably do a temporary add to PATH in the future if I find its required for something, it's just annoying to have to do that every time.

Thanks again for the help!

StarGeek

Quote from: srb0501w on January 01, 2024, 04:51:51 PMI guess I will look up Perl if I need to customize this command more. I have a little more experience with RegEx, so I may start there instead.

I learned Perl mostly through the various StackExchange sites.  Searching Google with  site:stackoverflow.com Perl <what I want to do> usually gives me a code snippet that I would just need to reformat to be used in exiftool.  Same for RegEx.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype