Copying filenames in a specific way
Moderators: Hacker, petermad, Stefan2, white
Copying filenames in a specific way
Hi,
I wonder if there is a way of simplifying what I frequently have to do. I need to copy filenames to the clipboard but I need them in the following format:
filename1.ext; filename2.ext; filename3.ext;
When I use built in Copy selected names to clipboard option it copies them like that:
filename1.ext
filename2.ext
filename3.ext
so what I have to do is paste it to some text editor and replace carriage return character with ;[SPACE] which is very time consuming if done over and over again.
So is there a way of copying filenames to the clipboard the way I need?
Thanks
I wonder if there is a way of simplifying what I frequently have to do. I need to copy filenames to the clipboard but I need them in the following format:
filename1.ext; filename2.ext; filename3.ext;
When I use built in Copy selected names to clipboard option it copies them like that:
filename1.ext
filename2.ext
filename3.ext
so what I have to do is paste it to some text editor and replace carriage return character with ;[SPACE] which is very time consuming if done over and over again.
So is there a way of copying filenames to the clipboard the way I need?
Thanks
The simplest way to make fast your repetitive operation is to use the macro method.
A macro is a sequence of operation which you must register and that you can repeat any time you need to.
For do that I use Notepad++, an open source text editor that I have also set as my default totalcmd editor (F4 button),
I suggest to download it from this web address:
notepad-plus-plusDOTorg
I have tried to make a macro for solve your problem, you should copy the following code:
Then, if your Operating system is Windows XP, you have to paste with notepad.exe (or another text
editor which isn't Notepad++) the code in this file:
Otherwise, if you have got another Operating System, you have to search the folder where shortcuts.xml file is stored.
The code must be placed between delimiters of the macro section:
1) Paste the copied file names in Notepad++ text editor.
To make sure the macro works, the cursor must be placed after the last character of final filename (filename3.ext):
The output is this:
I arbitrarily assigned the macro name (ClipBoard), but you can change it if you want.
Note that you can set a shortcut to invoke the macro.
A macro is a sequence of operation which you must register and that you can repeat any time you need to.
For do that I use Notepad++, an open source text editor that I have also set as my default totalcmd editor (F4 button),
I suggest to download it from this web address:
notepad-plus-plusDOTorg
I have tried to make a macro for solve your problem, you should copy the following code:
Code: Select all
<Macro name="ClipBoard" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="1" message="2170" wParam="0" lParam="0" sParam=";" />
<Action type="0" message="2302" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=";" />
<Action type="0" message="2302" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=";" />
<Action type="0" message="2318" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2326" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2453" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2326" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2310" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2310" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2310" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2310" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2451" wParam="0" lParam="0" sParam="" />
</Macro>
editor which isn't Notepad++) the code in this file:
Or more generally the path is it:C:\Documents and Settings\YourUserName\Application Data\Notepad++\shortcuts.xml
Please don't perform that copy/paste operation with Notepad++, because it does not allow to change its configuration files if it is open.%userprofile%\Application Data\Notepad++\shortcuts.xml
Otherwise, if you have got another Operating System, you have to search the folder where shortcuts.xml file is stored.
The code must be placed between delimiters of the macro section:
Once this procedure done:<Macros> (first delimeter)
<Macro name="Example"........>
....
Various action that macro make
....
</Macro>
</Macros> (second delimeter)
1) Paste the copied file names in Notepad++ text editor.
To make sure the macro works, the cursor must be placed after the last character of final filename (filename3.ext):
2) Choose the macros menu by clicking on it --> click on "ClipBoard" (or press Enter when it is highlighted).filename1.ext
filename2.ext
filename3.ext| <--- cursor
The output is this:
Your problem should be solved.filename1.ext; filename2.ext; filename3.ext;
I arbitrarily assigned the macro name (ClipBoard), but you can change it if you want.
Note that you can set a shortcut to invoke the macro.
Last edited by snake8 on 2012-06-03, 12:20 UTC, edited 3 times in total.
Search/replace is what I currently do but it does take a lot of time if I do the whole thing a lot. That macro does speed things up a bit so that's always some progress but ideally I would prefer not to use any text editor as an intermediate step at all, i.e. copy in desired format straight from the TC but it looks like it's not possible.
Hi,
An alternative approach could be the use of Lefteous' tool Lst2Clip (see http://www.totalcmd.net/plugring/list2clip.html). It has extensive ways for copying a file list to the clipboard, and can also replace strings in the process. The way I see it you only need to replace the CRLF sequence by '; '. I'm not sure if this is possible (I'm currently not using the tool myself), but it seems worth the experiment, as the documentation is very clear.
Regards, EricB
An alternative approach could be the use of Lefteous' tool Lst2Clip (see http://www.totalcmd.net/plugring/list2clip.html). It has extensive ways for copying a file list to the clipboard, and can also replace strings in the process. The way I see it you only need to replace the CRLF sequence by '; '. I'm not sure if this is possible (I'm currently not using the tool myself), but it seems worth the experiment, as the documentation is very clear.
Regards, EricB
Save this as "filenames.cmd" or something:
and put it on a button with parameter %F
Code: Select all
setlocal enabledelayedexpansion
for /F %%I in (%1) do (
set concat=!concat! %%I;
)
echo !concat! >filelist.txt
pause
endlocal
I made a small program in C language, modified from another one (that I've found on net) that reads lines from a file, that should solve your problem.
It reads and modifies the clipboard in your desired form (in a row, separated by ; and tab)... Later you can paste the modified row everywhere you want.
It works in combination with another .exe program that copy/write the clipboard (not made by myself).
You must launch the .bat file (CopyLinesToClipboard.bat) in order to execute the combined programs.
Synthetically, the program works like this:
1)Copy your text lines to the clipboard
2)Launch CopyLinesToClipboard.bat (your clipboard will be overwritten in the way you need it)
3)You can paste the modified clipboards everywhere you want.
You can find the compressed zip file that contains the program (it contains the source code too) here: CopyLinesToCliboard
(I've uploaded the zip file from site droplr file hosting: http://d.pr)
This link lasts one week from today (3 jun).
You can unpack the folder in the zip archive in the path you want (it is a portable a program).
You can do a shortcut of the .bat file (CopyLinesToClipboard.bat) directly into totalcommander for using this program (or in the desktop).
From total commander user guide: - Operation - userinterface - the button bar:
It reads and modifies the clipboard in your desired form (in a row, separated by ; and tab)... Later you can paste the modified row everywhere you want.
It works in combination with another .exe program that copy/write the clipboard (not made by myself).
You must launch the .bat file (CopyLinesToClipboard.bat) in order to execute the combined programs.
Synthetically, the program works like this:
1)Copy your text lines to the clipboard
2)Launch CopyLinesToClipboard.bat (your clipboard will be overwritten in the way you need it)
3)You can paste the modified clipboards everywhere you want.
You can find the compressed zip file that contains the program (it contains the source code too) here: CopyLinesToCliboard
(I've uploaded the zip file from site droplr file hosting: http://d.pr)
This link lasts one week from today (3 jun).
You can unpack the folder in the zip archive in the path you want (it is a portable a program).
You can do a shortcut of the .bat file (CopyLinesToClipboard.bat) directly into totalcommander for using this program (or in the desktop).
From total commander user guide: - Operation - userinterface - the button bar:
You can easily add buttons to the button bar using Drag&Drop (with pressed SHIFT key).
Autohotkey can do it, tested. The postmessage is equivalent to copynamestoclip, the string replace replaces 'r'n with ";space". But you need autohotkey installed or a compiled exe.
Code: Select all
IfWinActive, ahk_class TTOTAL_CMD
{
Clipboard := ""
PostMessage, 1075, 2017
ClipWait, 1
StringReplace, clipboard, clipboard, `r`n,;%A_Space%, All
}
I admit that I expected that this solution would not be liked (totally) to you, but I liked tab instead of space.paw3lk wrote:Thanks again for your replies.
snake8, your solution works almost right, the only thing is that what separates filenames is not ;SPACE but ;TAB. Unless I'm using it incorrectly?
Lst2Clip looked promising but doesn't seem to support replacing carriage return character.

Anyway:
EDIT: I've made some corrections, download new version at this link: program fixed (click)