New command: cm_CopyRelativeNamesToClip - Copy relative file names

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
pplupo
Member
Member
Posts: 102
Joined: 2019-12-02, 16:26 UTC
Location: Canada
Contact:

New command: cm_CopyRelativeNamesToClip - Copy relative file names

Post by *pplupo »

At the moment we have:
cm_CopyFullNamesToClip
ex:
c:\users\username\desktop\a.txt
c:\users\username\desktop\b.txt
c:\users\username\desktop\subdir\c.txt

cm_CopyNamesToClip
ex:
a.txt
b.txt
c.txt

My suggestion is a cm_CopyRelativeNamesToClip
ex:
a.txt
b.txt
subdir\c.txt

The base path would be the selected panel's path.

When is this useful?

When we want to capture a list of all files in a directory and subdirectory, but we don't want to disclose the full path or it is not relevant.
Currently, what I do is to ctrl+b to have all files listed in the panel.
Then I ctrl+a to select them all.
I use cm_CopyFullNamesToClip but then I have to do some cleanup.
Then I have to ctrl+v that into notepad++ and replace the c:\... to clear the absolute part of the path. And ctrl+a and ctrl+c again.

If I had the cm_CopyRelativeNamesToClip, a simple ctrl+b, ctrl+a, cm_CopyRelativeNamesToClip would get the job done.




Subject adjusted by moderator to make it more clear.
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Re: Copy relative file names

Post by *HolgerK »

- download and install: https://totalcmd.net/plugring/list2clip.html
- create a usercommand (usercmd.ini):

Code: Select all

[em_CopyRelativeNamesToClip]
button=%COMMANDER_PATH%\Addons\Lst2Clip\Lst2Clip.exe
cmd=%COMMANDER_PATH%\Addons\Lst2Clip\Lst2Clip.exe
param=/R:"%P"="" /L:"%L"
path=%COMMANDER_PATH%\Addons\Lst2Clip\
menu=Lst2Clip (relative path)
- use em_CopyRelativeNamesToClip for a button (copy code into clipboard; paste into buttonbar):

Code: Select all

TOTALCMD#BAR#DATA
em_CopyRelativeNamesToClip

%COMMANDER_PATH%\Addons\Lst2Clip\Lst2Clip.exe
Lst2Clip (relative path)

0
10015
- or assign a shortcut to the usercommand (wincmd.ini):

Code: Select all

[Shortcuts]
CS+R=em_CopyRelativeNamesToClip
HTH
Holger
Make our planet great again
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Copy relative file names

Post by *petermad »

Currently, what I do is to ctrl+b to have all files listed in the panel.
Then I ctrl+a to select them all.
I use cm_CopyFullNamesToClip but then I have to do some cleanup.
In stead of using cm_CopyFullNamesToClip you can use this em_command

Code: Select all

[em_saveselection]
cmd=SAVESELECTION
param="%PSELECTEDFILES.txt"
menu=Save file names in the file SELECTEDFILES.txt
It will save the file names with relative path.

You can combine it all in one em_command

Code: Select all

[em_branchview_saveselection]
cmd=cm_DirBranch 1,cm_SelectAllFiles,em_saveselection,cm_DirBranch 2
menu=Open Branch view, save file names in the file SELECTEDFILES.txt, close branch view

if you make an extra em_command:

Code: Select all

[em_goto_selectedfilestxt]
cmd=cd SELECTEDFILES.txt
then you can automatically go to the new file with this:

Code: Select all

[em_branchview_saveselection]
cmd=cm_DirBranch 1,cm_SelectAllFiles,em_saveselection,cm_DirBranch 2,em_goto_selectedfilestxt
and if you want the filename automatically opened for renaming:

Code: Select all

[em_branchview_saveselection]
cmd=cm_DirBranch 1,cm_SelectAllFiles,em_saveselection,cm_DirBranch 2,em_goto_selectedfilestxt,cm_Wait 100,cm_RenameSingleFile
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Re: Copy relative file names

Post by *HolgerK »

Alternative solution using Powershell:

Code: Select all

[em_CopyRelativeNamesToClip]
button=WCMICONS.DLL,45
cmd=powershell.exe
param=(Get-Content '%L').Replace( '%P', '')|Set-Clipboard
menu=relative paths to clipboard
iconic=1
Regards
Holger
Make our planet great again
pplupo
Member
Member
Posts: 102
Joined: 2019-12-02, 16:26 UTC
Location: Canada
Contact:

Re: Copy relative file names

Post by *pplupo »

2HolgerK, I'll try your first suggestion as it seems it does exactly what I am talking about. Thank you and 2petermad for all the other suggestions as well.

However, I still think that this should be part of standard TC commands. It just feels like it's missing. We have bare file names and absolute file path+names, but we don't have relative file path+names. To achieve this, we need to add a plugin. It just feels like it's missing and it wouldn't be that hard to do considering we have the absolute path+names already implemented and we have the panel's directory to know what should be removed from (or not added to) the path (depending on how it was implemented).

Don't you feel that since we already have these 2 ways to copy file lists, the 3rd one I'm suggesting is a logical complement?
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Copy relative file names

Post by *petermad »

2pplupo
To achieve this, we need to add a plugin
Just to make it clear: My suggestion does not need a plugin - it uses functions already build into TC.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Re: Copy relative file names

Post by *HolgerK »

Nothing against a build in command (my solution won't work with search results), ... but adding some lines to usercmd.ini is not a big deal
HolgerK wrote: 2021-06-05, 13:15 UTC Alternative solution using Powershell:..
and is available right now.
And PowerShell is part of Windows since W7 (no additional installation required).
We have bare file names and absolute file path+names, but we don't have relative file path+names.
we have more:

cm_CopyNamesToClip=2017;Copy filenames to clipboard
cm_CopyFullNamesToClip=2018;Copy names with full path
cm_CopyNetNamesToClip=2021;Copy names with UNC path
cm_CopyFileDetailsToClip=2036;Copy all shown columns
cm_CopyFpFileDetailsToClip=2037;Copy all columns, with full path
cm_CopyNetFileDetailsToClip=2038;Copy all columns, with UNC path
cm_CopyHdrFpFileDetailsToClip=2091;Copy all columns, with headers+full path
cm_CopyHdrNetFileDetailsToClip=2092;Copy all columns, with headers+UNC path

at least three commands are needed:

cm_CopyRelativeNamesToClip ;Copy names with relative path
cm_CopyRelativeNamesDetailsToClip ;Copy all columns, with relative path
cm_CopyHdrRelativeFileDetailsToClip ;Copy all columns, with headers+relative path

Regards
Holger
Make our planet great again
pplupo
Member
Member
Posts: 102
Joined: 2019-12-02, 16:26 UTC
Location: Canada
Contact:

Re: Copy relative file names

Post by *pplupo »

petermad wrote: 2021-06-07, 15:07 UTC 2pplupo
To achieve this, we need to add a plugin
Just to make it clear: My suggestion does not need a plugin - it uses functions already build into TC.
Your suggestion also doesn't do quite the same thing, right? It creates a file with what should end up in the clipboard. ;-)
pplupo
Member
Member
Posts: 102
Joined: 2019-12-02, 16:26 UTC
Location: Canada
Contact:

Re: Copy relative file names

Post by *pplupo »

HolgerK wrote: 2021-06-07, 21:47 UTC Nothing against a build in command (my solution won't work with search results), ... but adding some lines to usercmd.ini is not a big deal
HolgerK wrote: 2021-06-05, 13:15 UTC Alternative solution using Powershell:..
and is available right now.
And PowerShell is part of Windows since W7 (no additional installation required).
We have bare file names and absolute file path+names, but we don't have relative file path+names.
we have more:

cm_CopyNamesToClip=2017;Copy filenames to clipboard
cm_CopyFullNamesToClip=2018;Copy names with full path
cm_CopyNetNamesToClip=2021;Copy names with UNC path
cm_CopyFileDetailsToClip=2036;Copy all shown columns
cm_CopyFpFileDetailsToClip=2037;Copy all columns, with full path
cm_CopyNetFileDetailsToClip=2038;Copy all columns, with UNC path
cm_CopyHdrFpFileDetailsToClip=2091;Copy all columns, with headers+full path
cm_CopyHdrNetFileDetailsToClip=2092;Copy all columns, with headers+UNC path

at least three commands are needed:

cm_CopyRelativeNamesToClip ;Copy names with relative path
cm_CopyRelativeNamesDetailsToClip ;Copy all columns, with relative path
cm_CopyHdrRelativeFileDetailsToClip ;Copy all columns, with headers+relative path

Regards
Holger
I agree that these 3 should be added. :-) I think it's just natural, useful and it makes sense.
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Copy relative file names

Post by *petermad »

pplupo wrote: 2021-06-09, 21:58 UTC
Your suggestion also doesn't do quite the same thing, right? It creates a file with what should end up in the clipboard. ;-)
Sure - I am not against your suggestion, just giving you a workaround in case the request is not honored.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
pplupo
Member
Member
Posts: 102
Joined: 2019-12-02, 16:26 UTC
Location: Canada
Contact:

Re: Copy relative file names

Post by *pplupo »

petermad wrote: 2021-06-10, 00:06 UTC
pplupo wrote: 2021-06-09, 21:58 UTC
Your suggestion also doesn't do quite the same thing, right? It creates a file with what should end up in the clipboard. ;-)
Sure - I am not against your suggestion, just giving you a workaround in case the request is not honored.
And that's why I thanked you. :-)
Post Reply