TC32: If no files are selected, the %F parameter prevents all other parameters from being sent to the command line
Posted: 2023-03-08, 13:31 UTC
If you have the option Show parent dir [..] also in root of drive enabled, and you invoke a command that uses the %F list parameter, along with ANY other parameters, but you don't have any files selected, or a file under the cursor, Total Commander doesn't send anything at all to the command line.
To reproduce this bug;
Go to Configuration > Options > Display, and check Show parent dir [..] also in root of drive.
Open Notepad and enter the following;
Save it as test.bat, then create a new button on the Buttonbar that points to it, and include the parameters %P %T %N %F. Make sure that no files are selected and that the cursor is on the [..] at the top of the source window.
Instead of printing the source and target paths as expected, it will simply print ECHO is off., because nothing was sent to the command line. Now delete the %F parameter, then try it again, and it will print the source and target paths to the window, even though the %N parameter is as empty as %F was.
The contents (or lack thereof) of one parameter shouldn't negate the sending of completely separate parameters. As far as I can tell, %F is the only parameter that does this. %N doesn't interfere with other parameters, even if no files are seleceted/under the cursor.
I checked past versions of Total Commander, and it seems that it always behaved this way, at least back to v7.xx.
Of course, I know someone will ask why anyone would want to use the %F parameter, which creates a list of selected files, if no files are selected. The reason is as follows:
I made a script that converts files, and the button to call it is supposed to send both the target path and a list file, if anything was selected. The script checks to see if Total Commander sent it a list of files to process. If there's no list, it converts all the files in the directory. If I've selected any files, or even just left the cursor on a file, a list file will be created and sent to the script, and it will use that to only convert the selected files. It's meant to send the converted files to the target window, but that only works if I select the files. If I want it to do all the files without manually selecting them first, it puts the converted files in the same directory because it never receives the target path.
To reproduce this bug;
Go to Configuration > Options > Display, and check Show parent dir [..] also in root of drive.
Open Notepad and enter the following;
Code: Select all
@echo off
echo %1 %2 %3 %4
pause
Instead of printing the source and target paths as expected, it will simply print ECHO is off., because nothing was sent to the command line. Now delete the %F parameter, then try it again, and it will print the source and target paths to the window, even though the %N parameter is as empty as %F was.
The contents (or lack thereof) of one parameter shouldn't negate the sending of completely separate parameters. As far as I can tell, %F is the only parameter that does this. %N doesn't interfere with other parameters, even if no files are seleceted/under the cursor.
I checked past versions of Total Commander, and it seems that it always behaved this way, at least back to v7.xx.
Of course, I know someone will ask why anyone would want to use the %F parameter, which creates a list of selected files, if no files are selected. The reason is as follows:
I made a script that converts files, and the button to call it is supposed to send both the target path and a list file, if anything was selected. The script checks to see if Total Commander sent it a list of files to process. If there's no list, it converts all the files in the directory. If I've selected any files, or even just left the cursor on a file, a list file will be created and sent to the script, and it will use that to only convert the selected files. It's meant to send the converted files to the target window, but that only works if I select the files. If I want it to do all the files without manually selecting them first, it puts the converted files in the same directory because it never receives the target path.