Page 1 of 2
✅❓ Button/em_command parameter like [P] from MRT
Posted: 2020-02-04, 18:27 UTC
by Fla$her
Often, when working with command utilities, it's necessary to get the name of the parent folder without a path.
We have to reinvent the wheel in bat/wsh codes. It's high time to change that.
ghisler(Author), please finally simplify the buttons for codes with this parameter.
Maybe like [d], [t], [G] too. But with less priority.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-03-15, 17:09 UTC
by Fla$her
Bump for v.10
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-20, 21:53 UTC
by Fla$her
As a demonstration, I want to give an example of kludge in a .bat:
Code: Select all
@echo off & setlocal enabledelayedexpansion
set "d=%~dp0"&for %%i in ("!d!..\") do set "d=!d:%%~pi=!"
echo %d:~2,-1%
pause>nul
It's too bad that we have to resort to such dirty solutions (workarounds) instead of immediately getting the result without scripts.
It's strange that no one supported...
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 08:27 UTC
by ghisler(Author)
Do you mean %P but only the last part?
If yes, I would suggest the following implementation:
%B branch name: parent
%B0 branch name: same as %B
%B1 branch name: grandparent
%B2 branch name: two levels up, etc.
%Bt parent of target dir (no branch)
%Bt1 grandparent of target dir (no branch)
%Bt2 target dir, two levels up (no branch), etc.
%B-, %B-1, %B-2 etc.: do not use dirs from branch view, just from displayed path.
Example for the difference:
Source path: c:\dir1\dir2
File name: branch1\branch2\file.ext
Results:
%B | branch2 |
%B0 | branch2 |
%B1 | branch1 |
%B2 | dir2 |
%B- | dir2 |
%B-0 | dir2 |
%B-1 | dir1 |
%B-2 | (empty string) |
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 12:02 UTC
by NotNull
Fla$her wrote: 2021-04-20, 21:53 UTC
As a demonstration, I want to give an example of kludge in a .bat:
Code: Select all
@echo off & setlocal enabledelayedexpansion
set "d=%~dp0"&for %%i in ("!d!..\") do set "d=!d:%%~pi=!"
echo %d:~2,-1%
pause>nul
A little less 'kludgy':
Code: Select all
@echo off & setlocal
for %%X in (%~dp0.) do echo "%%~nxX"
pause
BTW: There is a bug in your script. Try it in C:\folder : it will strip the last character of teh foldername.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 18:44 UTC
by Fla$her
ghisler(Author) wrote: 2021-04-21, 08:27 UTCDo you mean %P but only the last part?
Yes. [P] in MRT just about that.
ghisler(Author) wrote: 2021-04-21, 08:27 UTCIf yes, I would suggest the following implementation:
I would only be glad of such a variety!

What is the difference between Bt and B- ?
NotNull wrote:There is a bug in your script. Try it in C:\folder
In this case, no. %~dp0 always has a \ at the end and is needed to implement [P].
But in your version, there are definitely not enough quotation marks — "%~dp0.", as in names there can be
=;,) and
space.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 19:31 UTC
by NotNull
Yeah, quotes ... I forget them all the time (this was untested; should have mentioned that. But if you can create your version, you will have no problem fixing that

).
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 19:38 UTC
by NotNull
Forgot this:
Code: Select all
T:\Endwith_d>type parent.cmd
@echo off & setlocal enabledelayedexpansion
set "d=%~dp0"&for %%i in ("!d!..\") do set "d=!d:%%~pi=!"
echo %d:~2,-1%
pause>nul
T:\Endwith_d>parent.cmd
Endwith_
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-21, 20:09 UTC
by Fla$her
2
NotNull
This topic isn't about bat-codes, much less calling them from the console.
Fla$her wrote: 2021-04-20, 21:53 UTCgetting the result
without scripts.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-22, 13:46 UTC
by ghisler(Author)
What is the difference between Bt and B- ?
Bt would be the target directory (from the other panel). B- would be the source directory, ignoring any branch view subdirectory of the file under the cursor.
I have implemented it now and it will be in beta 7.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-22, 18:48 UTC
by Fla$her
2
ghisler(Author)
t = target, - = minus. Understood. Thanks.
I have implemented it now and it will be in beta 7.
Famously! Super!

I checked, everything is fine. Finally! Thanks a lot!
Eng. TOTALCMD.CHM doesn't have a description yet.
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-23, 10:19 UTC
by Fla$her
2
ghisler(Author)
Can you add B+ ?
Source path: c:\dir1\dir2
%B+ | C: |
%B+0 | C: |
%B+1 | dir1 |
%B+2 | dir2 |
%B+3 | (empty string) |
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-23, 13:56 UTC
by ghisler(Author)
I can add it, but should it really add the drive letter? Currently %B cuts the drive letter (or server name for UNC paths).
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-23, 18:50 UTC
by Fla$her
The drive letter is needed first, since sometimes you need to do something with the disk of the current directory.
Examples:
wmic volume where DriveLetter='D:' set Label="Data Label" |
PortableWinCDEmu.exe /unmount D: |
OSFMount.exe -d -m D: |
HD_Speed.exe /r /d D: |
BadNTFS.exe /l D: |
etc. |
Re: Button/em_command parameter like [P] from MRT
Posted: 2021-04-24, 02:31 UTC
by petermad
Fla$her wrote: 2021-04-23, 10:19 UTC
2
ghisler(Author)
Can you add B+ ?
Source path: c:\dir1\dir2
%B+ | C: |
%B+0 | C: |
%B+1 | dir1 |
%B+2 | dir2 |
%B+3 | (empty string) |
Support++