|
Title | CopyMoveOnList |
File Name | CopyMoveOnList.txt |
Description | Copy or move files and directories with names from one list to files and directories with names from another list |
Author | Vochomurka |
Parameters | Source_list, Target_list, Move |
Plugins Called | file, vec, osd |
Icon | |
Version | 1.0 |
Updated on | 01.07.2009 |
args From, To, Move local i, j, Text, Str, De, A, Item, Dest if(ctrl) Move = 1 if(not validpath(From)) do messagebox("ok error", "Source list is not specified", "CopyMoveOnList script") quit endif if(not validpath(To)) do messagebox("ok error", "Target list is not specified", "CopyMoveOnList script") quit endif local What = ifelse(Move, "Move ", "Copy ") local Source = file.readall(From) local v = vec.createfromlines(Source) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #1") quit endif local Target = file.readall(To) local w = vec.createfromlines(Target) if(w <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error #2") quit endif local FromC = vec.length(v) local ToC = vec.length(w) if(FromC == Toc) do for(i = 0; i < FromC; i++) From = v[i] CheckPath(From) To = w[i] CheckPath(To) Text = What ++ From ++ " to " ++ To osd.show(Text, "INFINITE", "14", "Arial", "-1", "255 000 000") if(Move) do file.move(From, To) else file.copy(From, To) endif osd.hide endfor quit endif local Cap = "Select file(s)/folder(s) to " ++ ifelse(Move, "move", "copy") Text = Cap ++ " FROM:" pickstring(Source, Text, 3) if(not _pickedline_) quit From = _pickedline_ De = word(From, 0) Text = Cap ++ " TO:" pickstring(Target, Text, 3) if(not _pickedline_) quit To = _pickedline_ A = word(To, 0) for(i = 1; i <= De; i++) for(j = 1; j <= A; j++) Text = word(From, i) - 1 Item = v[Text] CheckPath(Item) Text = word(To, j) - 1 Dest = w[Text] CheckPath(Dest) Text = What ++ Item ++ " to " ++ Dest osd.show(Text, "INFINITE", "14", "Arial", "-1", "255 000 000") if(Move) do file.move(Item, Dest) else file.copy(Item, Dest) endif osd.hide endfor endfor quit Function CheckPath(Path) if(not validpath(Path)) do messagebox("ok error", "Path " ++ Path ++ " is invalid", "CopyMoveOnList script") quit all endif quit
Source list is a text file containing file and directory (without ending backslash) names, one per line. Wildcards * and ? are allowed. Target list contains file and directory names, the latter ones with or without ending backslash. Full paths to these lists are first two parameters of the script. Third parameter, if present and equal to 1, implies moving files. The same result (move files rather than copy) is achieved with pressing the Ctrl key at the script execution.
If the third parameter is 0 or absent, the copying occurs.
If number of items in the source list is equal to that in the target list, then each item of the source list is copied/moved to the corresponding file/directory of the target list: first source item is copied/moved to the first target, second - to second, etc.
At the inequality of these numbers two dialog windows are shown in turn. In the first window representing the source list you can pick any number of files that should be copied/moved, in the second window (target list) you can pick any targets. So, each picked source item is copied/moved to each target item.
Example of the source list:
c:\One\Two.txt
d:\Three\Four\*.*
Example of the target list:
e:\Five\Six.htm
f:\Seven\Eight
Number of items is 2 for both lists, therefore the c:\One\Two.txt file will be copied to the e:\Five\Six.htm file that must exist. Source file is deleted if the third script parameter is 1, and not deleted otherwise. Then, all files with the d:\Three\Four\*.* mask are copied (or moved) to the f:\Seven\Eight directory.
Another example. Source list is:
e:\Nine\Ten.exe
c:\One
d:\Three\Four\*.*
Target list is the same as above.
While source list contains 3 items and target list contains 2 items, the dialog window with source list appears. Let's pick c:\One (a directory) and d:\Three\Four\*.* items, and press OK. In the target list let's choose only the f:\Seven\Eight directory. So, the whole c:\One directory and all files from d:\Three\Four\*.* will be moved (if third parameter is 1 or the Ctrl key is pressed) to f:\Seven\Eight. As a result, the f:\Seven\Eight\One directory will be created.
All Scripts | Total Commander | TotalCmd.net | PowerPro |