Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename media files corresponding to their order value #5701

Merged
merged 3 commits into from
Aug 15, 2023

Conversation

solth
Copy link
Member

@solth solth commented Jun 26, 2023

This PR adds a button to the metadata editor allowing users to rename all media files of the process according to the corresponding physical divisions ORDER attribute.

Bildschirmfoto 2023-06-26 um 09 54 05

The new filename will be padded with 0 on the left to reach a filename length that can be configured for each project in the project settings.

Bildschirmfoto 2023-06-26 um 09 55 38

The button is only displayed when the current user has the (new) permission to rename media files, which is not assigned to any role by default.

Bildschirmfoto 2023-06-26 um 09 55 02

After renaming the media files has finished, a result dialog will be displayed, showing the number of files renamed in all configured process folders.

Bildschirmfoto 2023-06-26 um 09 57 00

Filename changes will be reverted if the user does not explicitely save changes in the metadata editor. This approach is consistent with other functionalities in the editlor like uploading or removing images, which will also be reverted when leaving the metadata editor without clicking the "Save" button.

Fixes #5601

@solth solth requested review from subhhwendt and apiller June 26, 2023 07:59
@solth solth added the feature label Jul 8, 2023
@solth solth force-pushed the rename-media-files branch 2 times, most recently from 675b0aa to d5600f2 Compare July 21, 2023 07:56
@solth solth force-pushed the rename-media-files branch 2 times, most recently from 6a63400 to 6946744 Compare August 1, 2023 08:23
@markusweigelt markusweigelt self-requested a review August 1, 2023 15:45
Copy link
Collaborator

@markusweigelt markusweigelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and it works for me!

Suggestions:

  • Handling of error if number of filename length in project is too low for all images
  • A test for resetting the media names when user not save changes after media renaming.

How do you do this?
After media renaming i restarted the application. All images where found but the meta.xml doesn't changed. How do you save the current state?

@markusweigelt
Copy link
Collaborator

markusweigelt commented Aug 8, 2023

I approved the PR last week, but I am still struggling with the scenario where the media is renamed and not saved, or the preDestroy method is not executed due to errors from the server and/or client side.

However, I was unable to produce such an problem during my tests by stopping the server immediately after the replacement. Therefore, I will maintain the approval from my side.

@solth
Copy link
Member Author

solth commented Aug 8, 2023

  • Handling of error if number of filename length in project is too low for all images

This is indeed not required as the StringUtils library I used only pads the filename with zeroes if required. If the name is already longer than target length passed to the padding method, it will not be altered and work just with the original filename.

@solth solth merged commit 5deed70 into kitodo:master Aug 15, 2023
2 checks passed
@solth solth deleted the rename-media-files branch August 15, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename jpegs after changing sequence in Kitodo 3
2 participants