[TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

  • In the right panel create a test folder to copy files to, and enter that folder.
  • In the left panel go to c:\program files and select the folder "totalcmd" (make sure TC is installed there).
  • Press F5 to copy the TC folder to the other site and use filter:

    Code: Select all

    \totalcmd\language\ | \totalcmd\*
    Only totalcmd\language is copied to the other site, including the contents of the language folder.
  • Delete the copied files and folders.
  • Go to the left panel and again press F5 to copy the TC folder to the other site, but now use filter (backslash at the beginning removed):

    Code: Select all

    totalcmd\language\ | \totalcmd\*
    Besides totalcmd\language and the contents of the language folder, the whole folder structure (without files) is copied.
    Expected result: the same result as before.

    When specifically told which folder to include, TC should not copy other folders (without files). TC should walk through all folders to search for the subfolder to copy, but not copy all folders while doing so. Similar to how search doesn't show all folders in the search results when searching for a folder to include. Try this: Select TC's program folder in the left panel (make sure it is marked red), then do a search on selected files (only the TC folder) and search for the above mentioned expressions. You'll get the same results will both expressions.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

It's a bit hard to understand, but I will give it a try:
When you use the filter

Code: Select all

\totalcmd\language\ | \totalcmd\*
it tells Total Commander to only look for the folder \totalcmd\language\. You don't even need to use the | \totalcmd\* part because you have only selected the totalcmd folder before copying. It is only necessary if you have selected files in the base directory too.

However, when you use the filter

Code: Select all

totalcmd\language\ | \totalcmd\*
it tells Total Commander to copy files from the folder totalcmd\language\ anywhere below the current location. Therefore TC has to go through all the other subdirectories. For example, it would also copy files from a folder named totalcmd\wfx\totalcmd\language\ Since it has to go through all these subdirs, it also copies them. If you don't want that, you need to use the filter **\ behind the vertical line:

Code: Select all

totalcmd\language\ | \totalcmd\* **\
While you can also do this with the first filter, it's not necessary because Total Commander doesn't go through all the subdirs due to the more restrictive filter.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-12, 08:02 UTC It's a bit hard to understand, but I will give it a try:
I know how it works.
ghisler(Author) wrote: 2025-05-12, 08:02 UTC When you use the filter

Code: Select all

\totalcmd\language\ | \totalcmd\*
it tells Total Commander to only look for the folder \totalcmd\language\. You don't even need to use the | \totalcmd\* part because you have only selected the totalcmd folder before copying. It is only necessary if you have selected files in the base directory too.
Yes, it can be left out, but not when using the same search expression for the search function. The search function works different from the copy function in that it starts searching within selected folders as separate search destinations. Note that you can use a saved search for search operations and copy operations. I chose this expression to basically get the same results of the files found and the files copied.
ghisler(Author) wrote: 2025-05-12, 08:02 UTC However, when you use the filter

Code: Select all

totalcmd\language\ | \totalcmd\*
it tells Total Commander to copy files from the folder totalcmd\language\ anywhere below the current location. Therefore TC has to go through all the other subdirectories. For example, it would also copy files from a folder named totalcmd\wfx\totalcmd\language\ Since it has to go through all these subdirs, it also copies them.
My point is that "Since it has to go through all these subdirs, it also copies them." is a design choice. It's possible to implement it in such a way that it goes through all these subdirs without copying them, and only start copying when a folder matches totalcmd\language\. You did something similar for the search function where you go through all subdirs searching for a match, but not include them in the search results until you found a match. You likely did this by maintaining a flag indicating the mode, going through subdirs only looking for a folder, or going though subdirs to find search results. You could implement it in a similar way for the copy function. And in my opinion that would be more useful, more intuitive, and more consistent throughout functions that can use the same (saved) search.
ghisler(Author) wrote: 2025-05-12, 08:02 UTC If you don't want that, you need to use the filter **\ behind the vertical line:
That's not the same thing. That removes all empty folders, including those in the folders explicitly specified to include.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

Sorry, I don't want to change it. This is regularly used to copy just the directories, e.g. by using filter
*.notexisting
This tell TC to copy all files with extension "notexisting". If there are no such files, just the folders will be copied.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-13, 09:16 UTC Sorry, I don't want to change it. This is regularly used to copy just the directories, e.g. by using filter
*.notexisting
This tell TC to copy all files with extension "notexisting". If there are no such files, just the folders will be copied.
I’m not asking to change that functionality. Specifying folders to include would just limit the copied directories, which feels more intuitive and more consistent with how the search function works. Note that this is new functionality, so not breaking existing functionality:
ghisler(Author) wrote: 2025-04-06, 07:07 UTC Sorry, these special filters are NOT supported when copying. At the moment it's not planned to support them, sorry.
ghisler(Author) wrote: 2025-04-09, 09:50 UTC I will try adding the same traverse filters in F5 copy and regular search, or if this doesn't work, document the differences.
HISTORY.TXT wrote: 09.04.25 Added: F5 copy: Supports copying directories anywhere in subdirectories. For example, if "Only files of this type:" is set to "test\", the "test" folder will be found anywhere in the selected folders, while \test\ will match it only in the base directory (32/64)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

So you mean I need to append | **\ to the filter in some cases (e.g. when user filters by directory like totalcmd\language\) but not in others, e.g. when user only filters by extension only)? How to distinguish the cases?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-14, 08:29 UTC So you mean I need to append | **\ to the filter in some cases (e.g. when user filters by directory like totalcmd\language\) but not in others, e.g. when user only filters by extension only)? How to distinguish the cases?
No, specifying **\ in the exclude section is an entirely different thing.

I see it like this. The copy function copies files as well as folders. You can select a couple of empty folders and copy them for example.

The copying of folders (meaning folder names, not their contents) can be disabled by the special keyword "**\" anywhere in exclude section of the expression for "Only files of this type". So selecting empty folders and copying them with filter "| **\ ", copies nothing.

Specifying *.notexisting as a filter does not turn on copying empty folders. That's always turned on and can only be turned off by specifying **\ in the exclude section. So using *.notexisting doesn't instruct TC to do anything other than filtering files, same as when you exclude all files using "| *".

A side note:
A filter expression NOT ending with a backslash filters files only, this is different from the search function.
Searching for *.pdf will also find a folder named "my files with extension .pdf".
Copying with filter *.pdf does not exclude the folder "my files with extension .pdf".

Expressions ending with a backslash limit the scope for other type expressions. For the search function, it means limiting traversing into folders, for the copy function it means limiting the folders that are copied.

For example, using "*.pdf | somedir\" excludes folders named somedir to be copied.
Specifying "*.nonexisting | somedir\" doesn't suddenly make that the folder somedir is excluded, but that the folder structure of somedir does get copied.

The same applies when using a filter like "\somedir\ *.pdf". All other folders than somedir are not copied, and specifying "\somedir\ *.nonexisting" does not suddenly copy the folder structure of all other folders.

Specifying something like like "somedir\ *.pdf" (no leading backslash), limits the scope to any folder named "somedir" anywhere in the folder structure. Only the contents of folders named somedir are copied. But you currently implemented that the folder structure of all other folders are also copied. My argument is that it is more intuitive and consistent that this doesn't happen. But your counter argument is that if people specify *.nonexisting it should override the folder filter and copy the folder structure of all folders. That doesn't make sense to me.

If you're wondering about how to implement that, I already suggested to use a similar technique you used for the search function where you had a similar problem implementing expressions like somedir\ that are not in the exclude section.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

Sorry, I don't really understand your reasoning. How does what you want when writing
*.pdf | somedir\
differ from what currently happens when you write
*.pdf | somedir\ **\
?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-16, 09:13 UTC Sorry, I don't really understand your reasoning. How does what you want when writing
*.pdf | somedir\
differ from what currently happens when you write
*.pdf | somedir\ **\
?
Using somedir\ in the exclude section is not what is newly added to TC 11.55 and is not what my report is about.
Did you perhaps mean to say:
How does what you want when writing
somedir\ *.pdf
differ from what currently happens when you write
somedir\ *.pdf | **\
?
That particular example would make no difference, but if you use the example in this thread's subject:
How does what you want when writing
somedir\**\ *.pdf
differ from what currently happens when you write
somedir\**\ *.pdf | **\
?
Then, there is a difference. The whole folder structure within somedir\ (and only within somedir\) should be copied. Adding | **\ prevents this.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

No, adding **\ only prevents the copying of empty folders. It doesn't prevent the copying of files anywhere below somedir.
Example source structure:
somedir\a.pdf
somedir\a\a.pdf
somedir\b\a.pdf
somedir\empty\
a\somedir\a.pdf
a\somedir\a\a.pdf
a\somedir\a\empty\
a.pdf
a\a.pdf
a\a\a.pdf
b\a.pdf
b\empty\
Copying this with filter
somedir\**\ *.pdf | **\
results in the following structure:
somedir\a.pdf
somedir\a\a.pdf
somedir\b\a.pdf
a\somedir\a.pdf
a\somedir\a\a.pdf
So the only thing that doesn't get copied is empty folders anywhere in the path, even in the included dirs.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-19, 09:43 UTC So the only thing that doesn't get copied is empty folders anywhere in the path, even in the included dirs.
That's what I meant with "The whole folder structure within somedir\ (and only within somedir\) should be copied." I said folder structure, not folder contents.. Similar to the thread's subject, folder structure doesn't include the files in it.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

I don't think I can implement that, sorry. It can get very complex when the user adds a lot of included and excluded subdirectories. :(
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5895
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *white »

ghisler(Author) wrote: 2025-05-19, 10:41 UTC I don't think I can implement that, sorry. It can get very complex when the user adds a lot of included and excluded subdirectories. :(
The number of included or excluded subfolders doesn't matter at all. If it works for 1 or 2, it works for more as well. For the search function, you also said for something similar that you couldn't implement it, and then you did. I'm sure you can do it, but it will take some effort.

BTW, specifying it the following way doesn't work either: \**\somedir\**\ *.pdf
JOUBE
Power Member
Power Member
Posts: 1680
Joined: 2004-07-08, 08:58 UTC

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *JOUBE »

2ghisler(author):
I also advocate and suggest that nothing should be changed at this point.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50703
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.55rc1] Copy with filter "somedir1\**\" copies whole folder structure

Post by *ghisler(Author) »

After some hours of trying, I think I can actually get this to work. I just need to set the flag to not copy folders without content when there is any subfolder in the filter. Then when entering such a folder, I need to clear that flag.
Author of Total Commander
https://www.ghisler.com
Post Reply