How to open TC with two files selected?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
mbodicker
Junior Member
Junior Member
Posts: 3
Joined: 2024-09-12, 15:04 UTC

How to open TC with two files selected?

Post by *mbodicker »

Hi,

I'm trying to open Total Commander from a C# program I'm writing.

When I issue the following command

Code: Select all

tocalcmd .exe /n /l=<leftdirectory> /r=<rightdirectory>
everything works fine. Only the directories are selected.
When I issue the following command

Code: Select all

tocalcmd .exe /n /l=<left-fullfilename> /r=<right-fullfilename>
it works, but still only the directories are selected. No files are selected left or right.

I found a post here on this forum (https://www.ghisler.ch/board/viewtopic.php?t=80055) where someone basically asks the same thing, and the answer is to use the /A switch. But in the documentation, this is only for archives, and when I try it, it doesn't work.

Code: Select all

tocalcmd .exe /n /A /l=<left-fullfilename> /r=<right-fullfilename>
basically does the same as the previous commands.

What am I missing here? How can I open Total Commander and select a file left and right?

Thanks!

Marlon
User avatar
Dalai
Power Member
Power Member
Posts: 9948
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: How to open TC with two files selected?

Post by *Dalai »

Did you try to quote the paths to /L and /R when they contain spaces? And you do need /A when specifying files to avoid TC treating the files passed as archive(s).
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 16009
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to open TC with two files selected?

Post by *petermad »

You can use /P instead of /A to place the cursor on a directory instead of going into the directory.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
mbodicker
Junior Member
Junior Member
Posts: 3
Joined: 2024-09-12, 15:04 UTC

Re: How to open TC with two files selected?

Post by *mbodicker »

Dalai wrote: 2024-09-12, 15:29 UTC Did you try to quote the paths to /L and /R when they contain spaces? And you do need /A when specifying files to avoid TC treating the files passed as archive(s).
Hello Dalai,

Yes, both paths are always enclosed in quotes, so it's actually

Code: Select all

/l="<left-fullfilename>" /r="<right-fullfilename>"
I'm not quite sure what you mean by the second part - in the past I've used this piece of code to open Total Commander and show both directories (by passing full filenames), and TC has always shown the directories. I've never used the /A switch, I've only learned about it today when I found this forum.

If I understand you correctly, the /A switch is mandatory in order to show and select the files?

Thanks,

Marlon
mbodicker
Junior Member
Junior Member
Posts: 3
Joined: 2024-09-12, 15:04 UTC

Re: How to open TC with two files selected?

Post by *mbodicker »

petermad wrote: 2024-09-12, 15:39 UTC You can use /P instead of /A to place the cursor on a directory instead of going into the directory.
Hello Petermad,

Thanks for the information, but I actually want to go into the directory. Suppose I pass two filenames (c:\photos-new\image0005.jpg for left, and c:\photos-old\image0060.jpg for right), I want the left part of TC to show all files in c:\photos-new with image0005.jpg selected, and the right part of TC to show all files in c:\photos-old, with image0060.jpg selected.

I'm working on a piece of software which scans my hard drives and finds duplicate files, but which does not automatically deletes duplicates. I've made this in the past, and it automatically deleted the duplicates. This works to regain hard disk space, but cannot decide (for example) which file has the most descriptive name. My code would for example delete "Cover image of Random Album by Random Band.jpg", but keep "0x85efa40.jpg".

At the moment, Total Commander is opened so I can choose which file to delete, and which to keep, but I need to look at the output of my program to read the filenames, and then I have to find the files manually in both left and right part of Total Commander. With small directories this is easy, but when a directory holds thousands of files, it gets incredibly tedious. Hence why I want the files to be selected (if possible, obviously).

Marlon
User avatar
Dalai
Power Member
Power Member
Posts: 9948
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: How to open TC with two files selected?

Post by *Dalai »

mbodicker wrote: 2024-09-12, 16:30 UTCI'm not quite sure what you mean by the second part - in the past I've used this piece of code to open Total Commander and show both directories (by passing full filenames), and TC has always shown the directories.
[...]
If I understand you correctly, the /A switch is mandatory in order to show and select the files?
The switch /A doesn't matter for directories, but it matters for files. Example:

Code: Select all

totalcmd.exe /L=C:\pagefile.sys
Let's make one assumption for this example: There's a packer plugin installed that is either associated with .sys files or will try to detect the archive type by content (e.g. 7z or Total7zip plugin). In this example TC will try to open C:\pagefile.sys as an archive and since it can't do that (because it's exclusively locked by the system), TC will show an error message.

Another example:

Code: Select all

totalcmd.exe /L=C:\some_document.docx
TC will open that document as an archive because it's just a ZIP archive.

Conclusion: To avoid that error message and to avoid TC treating files as archives the switch /A is required.



I suggest to build up and test the full command on a CMD first. Once it works properly there you can incorporate it into your program.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
beb
Power Member
Power Member
Posts: 580
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: How to open TC with two files selected?

Post by *beb »

2mbodicker
I don't know what to say. As for me, everything does work as intended.
I have tested it in those ways:
tc.ps1 (PowerShell)

Code: Select all

$bin=$env:commander_exe

$l = "c:\Program Files"
$r = "c:\ProgramData"
& $bin /n /l=$l /r=$r

$l = "c:\Windows\explorer.exe"
$r = "c:\Windows\regedit.exe"
& $bin /n /A /l=$l /r=$r

sleep -s 3
tc.cmd (CMD)

Code: Select all

set "bin=%commander_exe%"

set "l=c:\Program Files"
set "r=c:\ProgramData"
start %bin% /n /l="%l%" /r="%r%"

set "l=c:\Windows\explorer.exe"
set "r=c:\Windows\regedit.exe"
start %bin% /n /A /l="%l%" /r="%r%"

timeout 3
In each case, upon launching the script/batch I can see TotalCommander being opened with:
a. the cursor set on the "c:\Windows\explorer.exe", and "c:\Windows\regedit.exe" files in the left and right panes respectively.
b. "c:\Program Files" and "c:\ProgramData" folders opened in the left and right panes respectively.

Note: the "commander_exe" variable implies a copy of TotalCommander has already been running, otherwise a literal path should be put there.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Post Reply