immich icon indicating copy to clipboard operation
immich copied to clipboard

feat(server): "{album}" in storage template

Open Hely0n opened this issue 2 years ago • 1 comments

See #2933

This allows for using {album} as a storage-template token

If an asset belongs to one or more albums, the name of the first album will be taken. If an asset doesn't belong to an album, the token will be skipped, so it will be placed in the root of the path where the folder would be created ({album} will be evaluated to ".")

If Assets are added to Albums, a storage migration job must be run. Otherwise if one uploads an asset directly into an album, it will be saved at the correct location without having to run it afterwards.

The only issue I see here, is the perfomance impact due to the changes in album.repository.ts. Right now, the albums of every asset will be queried when getById() or getAll() are called, even if they are currently not needed except for this case.

Hely0n avatar Jun 26 '23 19:06 Hely0n

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Oct 23, 2023 5:44pm

vercel[bot] avatar Jun 26 '23 19:06 vercel[bot]

This feature would be great for organiazing and syncing with other apps like onedrive (one copy is no copy). Lets bump it up, seems like not that big of a change.

Otsira avatar Aug 03 '23 16:08 Otsira

I can't wait for this feature to be added, it will be much easier to organize albums and photos.

fdaille avatar Aug 05 '23 07:08 fdaille

Hi to all,

Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich.

Many thanks

lgrawet avatar Sep 26 '23 12:09 lgrawet

Hi to all,

Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich.

Many thanks

Yes, this is also the only reason that prevents me from using it. I have hundreds of thousands of photos stored on my NAS, distributed in different folders, and I cannot upload all of them to Immic's library

@lgrawet

nodis avatar Oct 14 '23 04:10 nodis

Hi to all, Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich. Many thanks

Yes, this is also the only reason that prevents me from using it. I have hundreds of thousands of photos stored on my NAS, distributed in different folders, and I cannot upload all of them to Immic's library

@lgrawet

For that use case the external library feature might be the better fit. With that you do not have to import the files into immich file structure. I'm also wishing for nested albums for external libraries to have a de-facto filesystem view.

klaus1k avatar Oct 14 '23 09:10 klaus1k

Hi to all, Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich. Many thanks

Yes, this is also the only reason that prevents me from using it. I have hundreds of thousands of photos stored on my NAS, distributed in different folders, and I cannot upload all of them to Immic's library @lgrawet

For that use case the external library feature might be the better fit. With that you do not have to import the files into immich file structure. I'm also wishing for nested albums for external libraries to have a de-facto filesystem view.

@klaus1k
Could you please guide me on how to mount an external library?

nodis avatar Oct 14 '23 09:10 nodis

Hi to all, Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich. Many thanks

Yes, this is also the only reason that prevents me from using it. I have hundreds of thousands of photos stored on my NAS, distributed in different folders, and I cannot upload all of them to Immic's library @lgrawet

For that use case the external library feature might be the better fit. With that you do not have to import the files into immich file structure. I'm also wishing for nested albums for external libraries to have a de-facto filesystem view.

@klaus1k Could you please guide me on how to mount an external library?

Sure, this feature just released a month or two ago so it is relatively new! The corresponding documentation can be found here: https://immich.app/docs/features/libraries

This {album} template feature here is one I am looking forward the most. It would enable the possibility to backup "WhatsApp Images" "Screenshots",... in separate folders on the server, without having them mixed together with my "real" photos on the file/folder level.

klaus1k avatar Oct 14 '23 09:10 klaus1k

Hi to all, Is there anything new concerning the implementation of this feature ? I think this is the only thing refraining me from using immich. Many thanks

Yes, this is also the only reason that prevents me from using it. I have hundreds of thousands of photos stored on my NAS, distributed in different folders, and I cannot upload all of them to Immic's library @lgrawet

For that use case the external library feature might be the better fit. With that you do not have to import the files into immich file structure. I'm also wishing for nested albums for external libraries to have a de-facto filesystem view.

@klaus1k Could you please guide me on how to mount an external library?

Sure, this feature just released a month or two ago so it is relatively new! The corresponding documentation can be found here: https://immich.app/docs/features/libraries

This {album} template feature here is one I am looking forward the most. It would enable the possibility to backup "WhatsApp Images" "Screenshots",... in separate folders on the server, without having them mixed together with my "real" photos on the file/folder level.

While the External Album feature solves the problem for old media, the {album} feature is needed, if you plan to organize your new media laboriously inside immich. Imagine sorting everything in albums, but they are only present in this app, that for example doesn't work on Google TV, so you have to access them via DLNA. Or imagine having a problem with the immich database or immich itself and everything you have is your folder structure.

The {album}-Feature is more manditory than any of the other storage templates IMO and I don't understand, why my PR is ignored for months now, even if I communicated everything in discord while implementing it.

Hely0n avatar Oct 16 '23 07:10 Hely0n

While the External Album feature solves the problem for old media, the {album} feature is needed, if you plan to organize your new media laboriously inside immich. Imagine sorting everything in albums, but they are only present in this app, that for example doesn't work on Google TV, so you have to access them via DLNA. Or imagine having a problem with the immich database or immich itself and everything you have is your folder structure.

The {album}-Feature is more manditory than any of the other storage templates IMO and I don't understand, why my PR is ignored for months now, even if I communicated everything in discord while implementing it.

I'm absolutely with you, the {album} feature is very important! I am still using Photosync as my main backup solution from mobile just because I can replicate the folder/album structure from my phone to my server. I wish I could ditch Photosync, and only use immich in the future!

klaus1k avatar Oct 16 '23 13:10 klaus1k

Recently, I got acquainted with Immich, and I was very eager to use it. But since I have been keeping my photos in a certain directory structure for years and I don't want to change it, I did not find Immich as a solution for myself. But I think having album in storage template would allow me to keep my old structure and use Immich as well.

yottanami avatar Oct 16 '23 22:10 yottanami

@yottanami you can also use the library feature for this purpose.

I didn't have a chance to got back to this one yet

alextran1502 avatar Oct 16 '23 23:10 alextran1502

I made the following changes:

  • Rebased on main and resolve the merge conflicts
  • Don't load albums automatically for any of the repository methods
  • Lazily load albums if/when they are needed in a template
  • Add/document the {{album}} option in the web, under admin settings > storage template > variables > other options

Tested scenarios:

  • Two albums with the same name
  • An album named: ., .., ../parent, Album 1.2

Seems to work OK. There may be a lot of files in a single directory during an initial upload with this template.

image

jrasm91 avatar Oct 17 '23 00:10 jrasm91

@yottanami you can also use the library feature for this purpose.

@alextran1502 Thanks for the answer. Correct me if I am wrong, but as far as I got for using libraries, I need to add external libraries which are read-only. But I need to be able to delete some of the photos or mark them somehow to be deleted later

yottanami avatar Oct 19 '23 09:10 yottanami

@jrasm91 - I can see that this functionality has made it into v. 1.83.0 - but I can't get it to work for External Storage. Just want to verify if the {{album}} tag is only for import, or should it work when adding images via Import Path libraries?

nikolajhendel avatar Oct 30 '23 02:10 nikolajhendel

This does not apply to external libraries

jrasm91 avatar Oct 30 '23 12:10 jrasm91

Tried to add a feature request to include it for external storage import, but no luck being allowed to add (no idea why).

nikolajhendel avatar Oct 30 '23 23:10 nikolajhendel

@nikolajhendel this is only applied to the default upload library.

alextran1502 avatar Oct 31 '23 00:10 alextran1502

Thank you very much for merging my PR. We established Immich in our everyday life since then, and it's a true bessling.

I just found out a little bug, where ' in an Album name becomes ' in the folder name. Seems like Path.normalize is not normalizing enough 😅.

I will try to fix it soon and test other special characters.

Hely0n avatar Nov 07 '23 09:11 Hely0n

I "solved" it: #4917

Hely0n avatar Nov 09 '23 01:11 Hely0n

I would like to use the Album Keyword in my filenames and use it in combination with other Keywords. in a template like that it would be best to evaluate an empty album as an empty string. It would be even Better if it were possible to define characters that should only appear if there is an album name set. e.g. {_{album}} would be evaluated to "_ALBUM NAME" or ""

/{{album}}/ should obviously still be interpreted as "/./" and not as "//"

emhl avatar Nov 11 '23 12:11 emhl

Well I would like to store my assets into album folder structure but keep the original structure for assets not belonging to any album. Otherwise all unassigned assets end up in the root directory of the library. It there any possibility to do this ?

Thanks!

lgrawet avatar Nov 28 '23 20:11 lgrawet

I would like to use the Album Keyword in my filenames and use it in combination with other Keywords. in a template like that it would be best to evaluate an empty album as an empty string. It would be even Better if it were possible to define characters that should only appear if there is an album name set. e.g. {_{album}} would be evaluated to "_ALBUM NAME" or ""

/{{album}}/ should obviously still be interpreted as "/./" and not as "//"

I tried this using the built in helpers from https://handlebarsjs.com/guide/builtin-helpers.html#if but it doesn't seem to work either.

{{y}}/{{#if album}}{{MM}}_{{{album}}}{{else}}_{{MM}}{{/if}}/{{filename}}

nyejon avatar Apr 06 '24 13:04 nyejon