Ant Renamer 2 doesn't function if multiple "single"

You found an error in the program ? Report it here
Post Reply
pope5
Posts: 11
Joined: 2013-04-25 12:25:04

Ant Renamer 2 doesn't function if multiple "single&quot

Post by pope5 »

I have extented the registry, that I can mark multiple files in Windows Explorer (Win 7) and after klicking with the right mouse button I get a drop down list of different actions.

One is (due to the changes in the registry) to rename all marked files by means of Ant Renamer.

When I selected multiple files to be renamed, it happens, that I get a windows error reading "Ant Renamer 2 does not longer function". I klick the Button "Close Program".

Alle Files however are renamed, but a Window is still opened with the Title Ant Renamer 2.10.

The changes in the registry are:

[HKEY_CLASSES_ROOT\*\shell\Uppercase filename.ext]
"Icon"="C:\\Programme (User)\\AntRenamer\\renamer.exe"

[HKEY_CLASSES_ROOT\*\shell\uppercase filename.ext\command]
@="C:\\Programme (User)\\AntRenamer\\renamer.exe -b \"C:\\Programme (User)\\AntRenamer\\uppercase_fn.ext.arb\" -af \"%1\" -g -x"

The batch file for Ant Renamer reads:

<?xml version="1.0" encoding="UTF-8"?>
<AntRenamer Version="2.10.0" Date="12.03.2013">
<Batch>
<ChangeCase Option="2" AfterChars="- .+(" UseLocale="-1" IncludeExt="0" OnlyExt="0"/>
</Batch>
</AntRenamer>


Any Ideas, what is wrong?

Thank you for any help.

pope
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Possibly that Windows starts one instance of Ant Renamer per file, and at some point two try to save the config at the exact same time when exiting.
Or something else related to the fact that several instances are started in parallel.
Does it happen more if there are a lot of files? Or also for just two or three?
pope5
Posts: 11
Joined: 2013-04-25 12:25:04

Post by pope5 »

It is really a long, long time, since I put this problem into the list. And worst of all, I didn't look for a reply. When the error occured, I simply closed the error windows and continued with my work.

However, today, I decided to report this error again - and found my tread from 2013.

The error still exists (the Windows now read "Ant Renamer 2.11" and there are e.g. 2 windows with the message "Ant Renamer 2 does not function any longer".

This happens, when I want to process 2 or more files. and when the error occurs, there are as many windows (-1) as files are to be processed.

When I click the button in the error window this window and one of the other closes.

What can I do, to avoid this situation.

Thank you for any help.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

When I reproduce this, I get an explicit message:
Cannot open file "E:\dev\Renamer\dev\Renamer.xml". The process cannot access the file because it is being used by another process.
As I suspected, it is because both instances are launched at the exact same time and try to access the same config file.
It is not really an intended use.
There isn't really a solution with current version, and I'm not sure how I should solve that. Either I could find a clean way to redirect additional instances to the first one (and close it if there is no other requests made to it after one or two second, for example), but even with that if both start really close together the first one may not be far enough in the startup process to be detected by the other one. The other solution would be to wait a short time if the file is not available, then retry, I'm not sure it is very clean.
I'll put that on my to-do list but I'm not sure when I'll investigate that further.
See you in 2017 for the follow up next time you pass there ;)
pope5
Posts: 11
Joined: 2013-04-25 12:25:04

Post by pope5 »

@antp

I am a programmer for host systems. There I know the possibility, that I can setup a lock of a "resource" by any name e.g. "antrenamer". If another task sets up the same lock, the 2nd task is set to a bound state and released by the operating system, when the first task releases the resource.

Isn't it possible, to do this also with antrenamer immediately at the beginning of the program?

I hope, my reply was fast enough ;-).

regards

Peter
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Indeed, I could use a lock/mutex or something while accessing the config file, the other threads would have to wait only for a very short time (while reading/writing the file), that would be an easy fix...
I'll try that.
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Putting a mutex on the LoadFromFile & SaveToFile of the config seems to solve the problem.
Here is a test version (2.11.1 = exe of version 2.11.0 with only this added)
http://update.antp.be/renamer/test2111.zip

It is still not very clean to have one instead of the program running for each file, but at least it should not hang.
Maybe the problem will occur on other files (e.g. when reading .arb file or the bmp of the toolbars), but it is less likely as these are open as read only.
pope5
Posts: 11
Joined: 2013-04-25 12:25:04

Post by pope5 »

Excellent!

I didn't get the error any more. Even when I renamed 10 files at the same time.


However 2 things I want to mention:

(remember: I have set 2 entries in the context menue of the windows explorer to allow to uppercase or lowercase the marked filenames and its extensions. I do this by executing renamer with approbiate batch files.)

1. when I first tried the new version, the file extension was never changed. After I manually changed the value for the parameter IncludeExt="0" to -1 suddenly it worked - and continues to work.

2. under Win 7 the win explorer does not always update the list of filenames. In this case, I press F5 to see the renamed uppercase/lowercase filename and extension. I do not remember, that this was formerly the case.

Under Win XP, the display is never automatically updated. I always must press F5 to update the display. But this may be a problem of my Win XP.


Perhaps you can have a look to these 2 situations.

regards

Peter
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

pope5 wrote: After I manually changed the value for the parameter IncludeExt="0" to -1 suddenly it worked - and continues to work.
Well that corresponds to the option "Also apply to extension" in the program, if you check the box in the program it sets the value to -1, if you do not check it it sets the value to 0, I'm not sure to see what's the problem here :??:

For the refresh problem, the program rename files, if Windows Explorer does not refresh I can't really do anything... in my file manager (Altap Salamander) the changes are directly shown.
In some cases I know that the update of a folder by Explorer can take some time on some PCs, I'm not sure what causes it.
pope5
Posts: 11
Joined: 2013-04-25 12:25:04

Post by pope5 »

ok, I also do not see the reason, why uppercase the extension didn't work at the beginning. Currently it renames the filenames correctly.

And why the win explorer doesn't update the list of filenames is shurely a problem of the win explorer.

Most important is, that antrenamer does not longer terminate with an error. I just renamed a lot of files and there was no error in the renamer.

That's the best.

Regards

Peter
Post Reply