Swiss File Knife
a command line
free external tools,
- download the free swiss file knife base from sourceforge. - unpack the tool using winzip or unzip. - open the Windows Command Line.
sfk toclip copy stdin to clipboard as plain text. type test.txt | sfk toclip copies the content of ASCII file test.txt into clipboard. sfk list | sfk toclip copies a file listing of the current dir into clipboard. sfk fromclip [-wait] [-clear] dump plain text content from clipboard to terminal. -wait : block until plain text is available. -clear: empty the clipboard after reading it. Example: turn backslashes into forward slashes. Imagine you have the following text open within notepad: foo/bar/systems/alpha1.cpp foo/bar/systems/alpha2.cpp foo/bar/systems/beta1.cpp and for some reason you need the first line in a format like this: foo\bar\systems\alpha1.cpp then you may do it this way: 1. mark the first line using SHIFT + CURSOR keys. 2. press CTRL+C or CTRL+INSERT to copy it into clipboard 3. on the windows command line, run this command (e.g. from a batch): sfk fromclip +filter -rep x/x\x +toclip 4. back in the editor, press CTRL+V or SHIFT+INSERT, pasting the result from the clipboard. As you see, the line changed into "foo\bar\systems\alpha1.cpp". Example: reformat a spreadsheet line for further processing. Imagine you have the following Excel file open: and you need the data from line 3 as comma separated values. Now, if you click left into line 3: and press CTRL+C, the line is copied into clipboard, however as TAB- separated data. (at least that's the behaviour seen with Excel. Other packages like OpenOffice may behave different.) So if you say on the command line: sfk fromclip what you get is Foo Finance 4498542 1999 950 Dino how do you turn this into comma-separated values? we have 5 columns, therefore extend the above command like this [type the following all in ONE line]: sfk fromclip +filter -spat -sep "\t" -form "$col1;$col2;$col3;$col4;$col5" which will result in this output: Foo Finance;4498542;1999;950;Dino to make the data even safer for post-processing, we may surround every value by quotes this way [type the following all in ONE line]: sfk fromclip +filter -spat -sep "\t" -form "\"$col1\";\"$col2\";\"$col3\";\"$col4\";\"$col5\"" this is hard to type, of course, but if you place it into a .bat file, you only have to type it once. this results in: "Foo Finance";"4498542";"1999";"950";"Dino" As ever, the same result may be achieved in may ways. For example, you may also save the whole spreadsheet data as a comma-separated file, and then filter it by sfk filter export.csv "-+Foo Finance" which should produce the same line.
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.