Bug 357617 - Batch rename fails when using custom file extensions
Summary: Batch rename fails when using custom file extensions
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: AdvancedRename-file (show other bugs)
Version: 5.0.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-06 12:40 UTC by wuselwu
Modified: 2022-01-31 21:57 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.2.0


Attachments
Screenshot of error (53.37 KB, image/png)
2016-01-10 08:24 UTC, wuselwu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wuselwu 2016-01-06 12:40:11 UTC
I have added the extension "*.MTS" to the list of file extensions Digikam recognizes. This is the video format my camera produces, named e.g. 000001.MTS and so on.

When I want to batch rename this files according to my usual schema ([date:"yyyyMMdd_hhmmss"].[ext]{upper}), the rename process stops at the first file with this extension. It is renamed, however nevertheless an error message "<filename> cannot be renamed" or "<filename> does not exist" (translated from German, english messae may differ) pops up. I can start the rename process again, then it will rename the next video file and fail after that.

Reproducible: Always

Steps to Reproduce:
1. Create a picture folder containing not only JPGs and so on, but also video files with an extension not recognized by Digikam by default (e.g. *.MTS)
2. Do a batch rename with the format [date:"yyyyMMdd_hhmmss"].[ext]{upper} (F2 key)


Actual Results:  
Failure as soon as the process hits the first file with the custom extension, although this file is indeed renamed.

Expected Results:  
All selected files are renamed, regardless of the extension.

Tried this both on local ext4/btrfs filesystem as on NFS mounts
Comment 1 Maik Qualmann 2016-01-09 18:36:10 UTC
This problem is not to reproduce with digiKam-5.0.0-beta3 and also digiKam-4.14. I used a MTS video sample from the Web.

Maik
Comment 2 wuselwu 2016-01-10 06:23:04 UTC
I just tried it out with some edited MTS-files (files were not directly imported from the camera, but they were already in Digicam' library and I just re-renamed them in order to simulate the problem). Indeed in this case the renaming worked flawlessly!!

So it seems that only MTS-files "freshly imported from the camera" trigger the bug. (Which would make the bug description a bit misleading.)

I will create some mini video snippets in order to create a test case.
Comment 3 wuselwu 2016-01-10 08:24:58 UTC
Created attachment 96561 [details]
Screenshot of error

I tried to artificially recreate the problem (taking photos and mini video snippets with the camera, uploading, renaming), and was not able to recreate the situation.

However, when trying out a "real-life" rename, the bug appeared again, see the screenshot. 

To explain it: The error message says that the file "00000.MTS" does not exist. Under the error message, you see the file "20160108_195734.MTS", which indeed is the renamed "00000.MTS". However, when the error message popped up, the file was still named "00000.MTS", a fraction of a second after the error message the filename changed to"20160108_195734.MTS", this was when the screenshot was taken.

It seems like a timing problem or so?!
Comment 4 wuselwu 2016-01-10 09:11:36 UTC
An addition to that:
What is strange is, that Digikam already has applied the renanaming schema not only to the MTS file, but also to the next normal JPG file "20160109_083448.JPG", which is the picture previously named "P1060285.JPG".

I.e. the batch rename process renames all JPG files before the MTS file, the MTS file itself and also the next JPG file after the MTS file. And only then the rename process files because the MTS file does no longer exist with its original file name. Which is true, as it has been renamed as planned.
Comment 5 wuselwu 2016-01-17 13:46:54 UTC
For the record: Batch rename also fails when using this pattern and *.avi videos, so the custom file extension *.mts is not the reason.
Comment 6 caulier.gilles 2016-01-17 17:32:46 UTC
Possibility : the Exiv2 dependency to process Video metadata while renaming. Advanced Renamed will use Exiv2 to get video properties. If Exiv2 is not compiled with Video support, Advanced Renamed will fail

I think there is another report about this topic in bugzilla.

Gilles Caulier
Comment 7 wuselwu 2016-01-18 19:50:17 UTC
But why does the rename process fail AFTER it has renamed the file?

However, I also noticed that renaming video files sometimes does use the file date instead of the recording date. That happens randomly with video files from all sources I have (digicam, several smart phones).
Comment 8 wuselwu 2016-06-03 05:33:21 UTC
Problem still present in 5.0b6: I simply cannot batch rename video files (not only MTS, but some times also MP4) reliably. Sometimes Digikam renames a bunch and then fails, often it tries to rename a file it has already renamed (and therefore claims - rightly - that the file is not present). Sometimes the error message stops the renaming process, sometimes the process goes on in the background?!?! I simply don't understand the behaviour, it's consistent only inasfar as that batch renaming video files fails.
Comment 9 Maik Qualmann 2016-06-03 22:04:12 UTC
Strangely, the problem is not to reproduce here. I have a big album with all kinds of videos to test the video thumbnailer. I can rename up and down. No problem. Can you upload the messages from the console?

Maik
Comment 10 caulier.gilles 2016-06-19 18:11:31 UTC
Not reproducible here too.

Did you use Mysql database ?

Which Exiv2 library did you use exactly ?

Look in Help/Components Info dialog for details

Gilles Caulier
Comment 11 wuselwu 2016-06-20 03:24:56 UTC
I use openSUSE Tumbleweed (rolling release) and the problem has been present for as long as I can remember, probably over quite a few digikam- and exiv-versions. I just had time to file a bug a few months ago. 
That's very unspecific, I admit, I will try to create some kind of test case.
Comment 12 Maik Qualmann 2016-08-16 06:12:46 UTC
Git commit bb07b39065c7ba8d5b2763097ebdba05baa54a6b by Maik Qualmann.
Committed on 16/08/2016 at 06:10.
Pushed by mqualmann into branch 'master'.

filter out multiple signals from ThumbnailLoadThread
Related: bug 366769
FIXED-IN: 5.2.0

M  +2    -1    NEWS
M  +5    -12   utilities/advancedrename/advancedrenameprocessdialog.cpp

http://commits.kde.org/digikam/bb07b39065c7ba8d5b2763097ebdba05baa54a6b