Quantcast
Channel: XnView Software
Viewing all articles
Browse latest Browse all 4990

0.83: XnView MP can rename files to too long names

$
0
0
by JMM72 (Posted Thu Dec 22, 2016 12:23 am)
Hello. Using: XnViewMP Version 0.83 x64 (Oct 3 2016) Libformat version 6.92, under Windows 7 64 bit.

Using F2 to rename a file can cause the file to have a filename too long so it can't be accessed. This bug has two possible outcomes.

As you might already know, under Windows the complete path to a file must be under MAX_PATH which currently is 260 characters. That includes drive letter, all folders and slash separators, and the file's name and extension (unlike in old 8.3 fashion, period does count too). Usually you shouldn't be able to deal with files longer than this limit, unless you're using certain API functions which it seems you do. However, these functions aren't used consistently across all the libraries used by XMP, and outside XMP it's kind of rare. The normal way to find this problem is moving a folder which has a file near the limit inside a folder which with its combined name length causes the file to exceed the limit. Without special software you can't access these files, but you can always move to root the folder which has the file for a simple rename (or from now on, use XMP).

In the case of XMP, you can rename directly a file so it's complete path is longer than the limit. This can happen in two ways. First, we can try to rename to a filename with extension which is longer than the limit. In such case, XMP shows the overwriting file panel, without any file information, not knowing to do with such a long filename.

And second, we can rename a file with a name shorter than the limit, but still with complete path longer than the limit. So if the name is 240 characters long, and it's inside a 10 character long folder, and when renaming we add 15 chars more, XMP will happily rename it, and read the thumbnail, but you will not be able to see the image (neither trying to launch it from the browser, which shows a blank screen, nor from outside XMP, which shows a 'file not found' error from XMP. However with XMP you can rename the file back to shorter than the limit.

My suggestion is that while renaming a file, each time the text changes, you calculate the complete path length and if it's larger than MAX_PATH, crop the last chars of the name (without touching the extension) so it is still accessable both to XMP and to any other program without giving problems. You could even add an option to specify how many 'safe characters' are between the limit and the maximum length that XMP will allow to rename.

I haven't tested with the autorenamer since I use another specific tool for that and I'm not familiar with yours. I'd also check name and path length limits for the other OS XMP is released for.

Regards, JMM.

Read Main Topic

Viewing all articles
Browse latest Browse all 4990

Trending Articles