0.61: File listing: Suggestions and problem with slash

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, helmut, xnview

KlausT
Posts: 20
Joined: Thu Dec 31, 2009 10:54 am
Location: Paderborn, Germany

0.61: File listing: Suggestions and problem with slash

Post by KlausT »

I tested this feature using XnViewMP v0.61 with Windows XP.

I started with 5 image files Img01.jpg ... Img05.jpg in the folder "D:/Base/Sub1/Sub2/Sub3". The order of the images in subfolder Sub3 was rearranged by shifting Img05.jpg between Img02.jpg and Img03.jpg in XnViewMP's browser pane (Custom order). The file list with all 5 images selected was created using "Create > File listing...". The following picture shows extracts from the browser pane, the file listing dialog, and the resulting text file:
Filelist-1.jpg
As can be seen from the text file, the order of the images is correct, but the pathnames are not formed correctly because of the missing slash after subfolder Sub3.

Obviously this feature is designed to export image information, but a common usage of this feature is to export a pure file list (for example to save the DB result) and to import this file list via "File > Open file list..." in XnViewMP or in other programs. This does not work, even after fixing the pathnames, because XnViewMP recognizes the trailing tab after the filename as part of the extension. My expectation is that a file list as created by XnViewMP can be read by XnViewMP without modifications.

After deleting the tabs in the file list, XnViewMP imports the file list and shows the images in the file list as "<DB result>" (filter "Images" active, otherwise the head line will be shown as well):
Filelist-DBresult.jpg
As can be seen from this screenshot, the file list is sorted, so the customized order of the images in the file list is lost. It should be possible to view the images in the file list in the pregiven order.

Another problem concerns the {Folder name} tag as offered in the file listing dialog:
Filelist-2.jpg
My guess is that the {Folder name} tag is assigned to the folder where the image file resides. I assume that the correct folder name shows up as soon as the filename-bug is fixed. Another possible and useful meaning for "folder name" could be the relative pathname, starting with the "Base path" as configured for the database.

Another shortcoming is the inconsistent usage of the trailing slash after {Directory} tag and after {Folder name} tag: for {Directory} tag, the slash is added by XnViewMP by default, for {Folder name} tag, no slash is added.

Here some suggestions:
  • avoid the trailing tab (in the text file list, a tab makes only sense to separate 2 items);
  • no head line for a text file if requested (for example by an additional "Format"-entry: "Text without head line");
  • show the images in the order as given in the file list (using the file list as a .XnViewSort file);
  • don't add a trailing slash after {Directory} tag (let the user customize the pathname);
  • create a UTF-8 text file if requested (by an additional checkbox);
  • be more precise in the selection menu for a tag (the difference between "folder" and "folder name" is not obvious);
  • customize the separator in a pathname (slash or back-slash) and make Windows users happy.
Perhaps the first 2 points can be implemented as defaults in a "File->Save Selection" feature as suggested by John.
You do not have the required permissions to view the files attached to this post.
Klaus (running Windows)
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: File listing: Suggestions and problem with slash

Post by helmut »

Thanks for the long suggestion and bug report, Klaus. Below, I answer only to the path problem.

Bug: Subfolder missing in {Directory} and listed in {Folder}
I've reproduced your problem with the subfolder. :bugconfirmed: The problem is the fulle path (path + filename) is split in a wrong way: In the variable {Directory} the lowest folder is missing, whereas in the variable {Files} the lowest subfolder is included. Looks like two bugs but technically it's probably just one bug.

To reproduce:
Image files reside in a subfolder "C:\empty1\empty2\folder_with_images"

1. Browse folder "folder_with_images"
2. Select some images
3. Select "Create > File listing..."
4. Add two columns using the "+" button.
Column 1: {Directory}
Column 2: {Filename With Ext}
5. Create the file listing by pressing OK and then selecting an output file.

Output will look like this:
Directory Filename With Ext
C:/empty1/empty2/ folder_with_imagesImage002.JPG
C:/empty1/empty2/ folder_with_imagesImage003.pcx
C:/empty1/empty2/ folder_with_imagesImage004.JPG
C:/empty1/empty2/ folder_with_imagesImage005.pcx
Klaus wrote:
  1. avoid the trailing tab (in the text file list, a tab makes only sense to separate 2 items);
  2. no head line for a text file if requested (for example by an additional "Format"-entry: "Text without head line");
  3. show the images in the order as given in the file list (using the file list as a .XnViewSort file);
  4. don't add a trailing slash after {Directory} tag (let the user customize the pathname);
  5. create a UTF-8 text file if requested (by an additional checkbox);
  6. be more precise in the selection menu for a tag (the difference between "folder" and "folder name" is not obvious);
  7. customize the separator in a pathname (slash or back-slash) and make Windows users happy.
All your suggestions make much sense to me. Some comments:
Re A: Right, please no trailing tab.
Re B: There should be a checkbox to "Column Header" (like in XnView Classic)
Re C: I think there should be an option for the sorting: Some people might want XnView to sort the files and some might want to keep the order in the file list.
Re D: Not sure about this one. Please note that these placeholders are used in Batch renaming. In Batch conversion you never want your files to be renamed to something like folder_withimagesImage002.JPG.
Re E: Yes, there should be "Text (ASCII)" and "Text (UTF-8)".
Re F: Yes. The place holders cannot be changed (I guess), but a clear description in the menu would be good.
Re G: Yes, an option is needed, just like in XnView Classic. XnView should even recognize the Windows platform and use "\" as separator, whereas on other platforms it could use "/" by default.
User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Re: 0.61: File listing: Suggestions and problem with slash

Post by m.Th. »

Generally I agree with the previous posts.

However...
don't add a trailing slash after {Directory} tag (let the user customize the pathname);
Don't do anything with the fields.
The {Directory}/{Folder name}/{Filename With Ext} should output "AS IS" without no further processing.

The fields must be consistent:
Both {Directory} and {Folder name} should have BOTH the same ending: Either with the trailing (back)slash either without.

The fields must be descriptive:

Having C:\foo\blah\bar.jpg, at least for me, the fields have the following meaning:
{Directory} = c:\foo\blah
{Folder name} = blah
{Filename with Ext} = bar.jpg

IMHO there are universal conventions for this...

Implementation details:

Something like this: (in pseudo-pseudo code)

Code: Select all

{Filename with Ext} = ExtractFileName(cFullPath);
{Directory} = ExtractFileDir(cFullPath);
{Folder name} = ExtractFileName( {Directory} );
Where

Code: Select all

function ExtractFileName(const FileName: string): string;
var
  I: Integer;
begin
  I := LastDelimiter(PathDelim + DriveDelim, FileName);
  Result := Copy(FileName, I + 1, MaxInt);
end;

function ExtractFileDir(const FileName: string): string;
var
  I: Integer;
begin
  I := LastDelimiter(PathDelim + DriveDelim, Filename);
  if (I > 1) and (FileName[I] = PathDelim) and
    (not IsDelimiter( PathDelim + DriveDelim, FileName, I-1)) then Dec(I);
  Result := Copy(FileName, 1, I);
end;

//auxiliary function: LastDelimiter - gets the last occurrence of a certain chars by scanning the string backwards 

function LastDelimiter(const Delimiters, S: string): Integer;
var
  P: PChar;
begin
  Result := Length(S);
  P := PChar(Delimiters);
  while Result > 0 do
  begin
    if (S[Result] <> #0) and (StrScan(P, S[Result]) <> nil) then
      Exit;
    Dec(Result);
  end;
end;
Yes, the code is tested. ;) Very very tested. :)


Add a new field: {Full Path and File Name}


...Which will simply output the entire file path + file name: C:\foo\blah\bar.jpg

IMHO, this will be one of the most used fields. Don't leave the human factor to interfere where the output is already known. We need to streamline the workflow.

Add a button called 'Preview'

When one presses the 'Preview' button a simple window with a memo widget inside (IOW a barebone Notepad clone - you have already something like this in View | Themes | Dark Theme) to show how the file list will look like.
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -
KlausT
Posts: 20
Joined: Thu Dec 31, 2009 10:54 am
Location: Paderborn, Germany

Re: 0.61: File listing: Suggestions and problem with slash

Post by KlausT »

Helmut, thanks for your comments and for your assistance. I was not aware that John's original post is located in the "Suggestions" forum for XnView Classic...
helmut wrote: Re C: I think there should be an option for the sorting: Some people might want XnView to sort the files and some might want to keep the order in the file list.
XnViewMP offers already such a sorting option in the browser pane for regular folders containing a .XnViewSort file: selecting "Name" (for example) from the "Sort by" menu deactivates the "Custom" sort option and shows the files sorted by name. Selecting "Custom" again shows the files in pregiven order. This behaviour should work for "DB result" as well.
helmut wrote: Re D: Not sure about this one. Please note that these placeholders are used in Batch renaming. In Batch conversion you never want your files to be renamed to something like folder_withimagesImage002.JPG.
Maybe there's a misunderstanding: my suggestion is to let the user add the separator where appropriate, for example after a directory name, as I did in the example above. I assume that this file listing feature is not meant to do batch renaming (this will be done with "Tools > Batch rename...") or batch conversion (this will be done with "Tools > Batch convert...").
My understanding is that the file listing feature is primarily designed to export image information into various file formats (.txt, .csv, .xml) for further processing. It should be left up to the user whether or not s/he wants to have a trailing slash after a directory or folder name. Creating a file list which can be read in by XnViewMP (or another program, for example IrfanView in thumbnail mode) is just one simple usage of this feature.
Klaus (running Windows)