|Description||Copy file name(s) to the clipboard. Advanced replacement for Total Commander's command with numbers 2007-2009, 2017-2018, 2029|
("%L", "n|p|o|e|f|s|q", "depth", "slash", "prefix", "suffix", "quote")
|Plugins Called||file, ini, vec, clip|
|Icon||depends on parameters|
local fh = file.open(arg(1), "r") local Str, Counter, What, Depth, i, j, Path static Quote = esc(?+\"+, ?+\+) local Before = arg(5) local After = arg(6) local QuoteString = arg(7) if(QuoteString != "") do Before = replacechars(Before, QuoteString, Quote) After = replacechars(After, QuoteString, Quote) endif if(fh) do for each Str in fh if(Str) Counter++ endfor else messagebox("ok error", "File not opened", "FILE plugin error") quit endif What = case("lower", arg(2)) Depth = ifelse(miscplugin.is_int(arg(3)) == "1", arg(3), 0) file.restart(fh) local v = vec.create(Counter) if(not v) do messagebox("ok error", "Vector not created", "VEC plugin error") quit endif for(i = 0; i < Counter; i++) Str = file.readstring(fh) if(Depth) do ;Sub_ParsePath - name of script ParsePath; Path = runfile.Subs\Sub_ParsePath(Str, Depth) Path ++= "\" else Path = file.folder(Str) ++ "\" endif switch (What) case "n" v[i] = file.nametype(Str) break case "f" v[i] = Path ++ file.nametype(Str) break case "p" v[i] = remove(Path, -1) break case "o" v[i] = file.name(Str) break case "e" v[i] = file.type(Str) break case "s" v[i] = file.size(Str) break case "q" v[i] = Path ++ file.name(Str) break case "o" v[i] = file.name(Str) break case else messagebox("ok error", "Invalid key " ++ Quote ++ What ++ Quote, "ClipFileList Script") quit endswitch if(arg(4) != "") v[i] = replacechars(v[i], "\", arg(4)) v[i] = Before ++ v[i] ++ After endfor file.close(fh) Str = vec.makelines(v) clip.set(Str)
List To Clipboard or List2Clip utility is, as its readme says, "an improvement to the internal commands":
The more I used List2Clip, the more it annoyed me. Finally, since I have developed my script, I completely get rid of this utility.
Why List2Clip is better than my script? First, List2Clip can process network paths, while the script cannot. The fact is that my computer is a standalone one, and thus I am not able to debug the network functions. Second, List2Clip can replace "something" to "whatever", while the script cannot. I've just never being faced with the necessity to perform such replacements, though it can be easily implemented.
Why List2Clip is worse than my script? First, List2Clip cannot process quotes. Second, List2Clip cannot copy the file size(s), that I need badly.
Suppose there is a file c:\One\Two\Three\name.ext with size equal to 123 bytes. All the examples below deal with a single file, but the same works for a group, that is, when some files are selected.
First script parameter is always "%L". Second parameter can be one of the following (lower or upper case):
Third parameter is a path depth - number of subdirectory levels countuing from the current one to the root. Third parameter matters only if the second one is "p", "f" or "q", that is, deals with path. If the third parameter is "", zero or exceeds the maximum path depth (being 4 in our case), or is not an integer, the result is the same as if the third parameter doesn't exist. However, if the script requires fourth and/or subsequent parameter(s), the third parameter must be present. In this case the "" value is recommended.
For example, the script with parameters ("%L", "f", "2") puts Two\Three\name.ext to the clipboard.
Fourth parameter is a character or string to replace the "\" character. At creating web-pages the backslash usually requires to be replaced by "/". But if there is a need to replace the "\" with "_", just specify, for example ("%L", "f", "", "_"). It would copy c:_One_Two_Three_name.ext to the clipboard.
Fifth and sixth parameters are strings to add before and after the file name. Thus, to copy to the clipboard the <a href=c:/One/Two/Three>hyperlink text</a> string, specify the following parameters: ("%L", "p", "", "/", "<a href=", ">hyperlink text</a>").
Seventh parameter matters only if there is a need to add the double quote (") character to the clipboard. Parameter can have any value except for ", for example, quote. In this case the quote string in 5th and/or 6th parameter will be replaced with the double quote character. For example, let's put the hyperlink to the current file, considering path depth of 3, quoting the file name and replacing "\" with "/": ("%L", "q", "3", "/", "<a href=quote", "quote></a>", "quote"). It yields <a href="c:\One\Two\Three\name"></a>. The only thing to do is to paste the clipboard contents into your editor.
The only parameter the script requires is the first one always equal to %L. If there is no more parameters, the second is supposed to be "f" (Full file name). As it was said above, if third and subsequent parameters are not used, they can be omitted. Otherwise, they must be present, usually just as "".
For example, it you need to put the c:\One\Two\Three\name.ext - full filename string to the clipboard, specify the following script parameters: ("%L", "", "", "", "", " - full filename").
As to me, I created the button bar with many buttons each calling the ClipFileList script with various parameters.
However, if this script does not cover your needs, please refer to the ClipListDialog script.
|Main Page||Total Commander||PowerPro|