funkymonk wrote: 2023-07-25, 00:17 UTC When using the content of the clipboard as a file name
(especially during in-place rename (Shift+F6)
or in dialogs where file names can be entered),
TC truncates the content of the clipboard at the first newline char.
I would prefer to replace newlines by a spaces.
In the meantime we can use such a button (or usercmd called from a keyboard shortcut)
FROM text in clipboard:
When using the "content" of the clipboard as a file name
(especially C:\> during? in-place rename (Shift+F6)
or in dialogs where file names can be entered),
TC truncates the content of the clipboard at the first newline char.
I would prefer to replace newlines by a spaces.
TO single line in clipboard:
When using the content of the clipboard as a file name (especially C during in-place rename (Shift+F
USE:
One could use this powershell one-liner (one long line):
$C=((Get-Clipboard) -replace('[:\\/><?|"]','') -join ' ')-replace('\s+',' ');if($C.length -gt 100){Set-Clipboard ($C.substring(0,100))}else{Set-Clipboard $C}
Copy&Paste buttoncode:
8<------------------->8------------------------>8
TOTALCMD#BAR#DATA
powershell -windowstyle hidden
$C=((Get-Clipboard) -replace('[:\\/><?|"]','') -join ' ')-replace('\s+',' ');if($C.length -gt 100){Set-Clipboard ($C.substring(0,100))}else{Set-Clipboard $C}
wcmicons.dll,67
PoSh: clean-up the clipboard
1
-1
8<------------------->8------------------------>8
This needs PoSh v5 or newer, or a own/other clipboard handling commandlet
PS C:\Temp> host
Name : ConsoleHost
Version : 5.1.22000.2003
hope this works for others too...
Explanations:
$C=((Get-Clipboard) >>>> get clipboard content and store in variable $C
-replace('[:\\/><?|"]','') >>>> replace signs not valid in a file name by nothing (or to underscore if wanted: ,'_' )
-join ' ') >>>> join the single lines by an space (removing the line break signs \r\n)
-replace('\s+',' '); >>>> reduce multiple spaces to one
if($C.length -gt 100){Set-Clipboard ($C.substring(0,100))} >>>> shorten to max wanted return length = 100 signs
else{Set-Clipboard $C} >>>> if shorter anyway, just use that
Add a keyboard shortcut to an command:
usercmd.ini
[em_MyCommandName]
cmd=powershell -windowstyle hidden
param=$C=((Get-Clip . . . . . . . . Set-Clipboard $C}
iconic=1
To assign an keyboard shortcut key (hotkey) to an command, like CTRL+SHIFT+V, utilize
Configuration > Options > Misc. >> Redefine hotkeys (Keyboard remapping)
More about this all at >>> https://ghisler.ch/board/viewtopic.php?p=344777#p344777
Update:
need to write the wanted max length only once by using the $M var:
USE (one long line):
$C=((Get-Clipboard) -replace('[:\\/><?|"]','') -join ' ')-replace('\s+',' ');$M=100;if($C.length -gt $M){Set-Clipboard ($C.substring(0,$M))}else{Set-Clipboard $C}
$M=100 >>>> set max wanted length to return to 100 signs
Alternative , also add extension:
TO:
When using the content of the clipboard as a file name (especially C during in-place rename (Shift+F.txt
USE (one long line):
$C=((Get-Clipboard) -replace('[:\\/><?|"]','') -join ' ')-replace('\s+',' ');$M=100;if($C.length -gt $M){$R=($C.substring(0,$M))}else{$R=$C};$R=($R -replace('(\.+$|\s+$)'))+'.txt';Set-Clipboard $R
Once again adjusted in detail:
$C=((Get-Clipboard) -replace('[:\\/><?|"]','') -join ' ')-replace('\s+',' ');$M=100;if($C.length -gt $M){$R=($C.substring(0,$M))}else{$R=$C};$R=($R -replace('([.\s]+$)'))+'.txt';Set-Clipboard $R