|
Title | CheckAscCounter |
File Name | CheckAscCounter.txt |
Description | Check whether files are numbered in ascending order |
Author | Vochomurka |
Parameters | ("%P", "%O", "%E") |
Plugins Called | win, file, miscplugin, clip |
Icon | |
Version | 1.4 |
Updated on | 18.04.2019 |
args Path, Name, Ext if(!Ext) Ext = "*" Ext = "." ++ Ext local hwnd = win.handle("c=TTOTAL_CMD") local Exepath = win.exepath(hwnd) local Len = length(Name) local mpDlgCaption = "CheckAscCounter Script" local mpIcon = "e:\Storage\Graphics\Icons\User\Incr.ico" local i, j, Char, mpDlgText, Prev, Cur local Quote = esc(?+\"+, ?+\+) local CtC = "&Copy to Clip" local Gt = "&Go to" for(i = Len; i > 0; i--) Char = Name[i - 1] if(not miscplugin.is_int(Char)) break endfor switch (i) case Len Char = "File name " ++ Name ++ Ext ++ " contains no counter" messagebox("ok error", Char, mpDlgCaption) quit case 0 Char = Name Name = "" break case else Char = Name[i, Len - 1] Name = Name[0, i - 1] endswitch local Digits = length(Char) local Total = repeat("9", Digits) for(i = eval(Char); i <= Total; i++) Len = fill(repeat("0", Digits), i) Cur = Path ++ Name ++ Len ++ Ext miscplugin.BalloonTip(1, "information", i, "timeout=5") if(!validpath(Cur)) do mpDlgText = "First missing file is '" ++ Cur ++ "'" local Ans = miscplugin.messagebox(1, Gt, CtC, "&Exit") if(Ans == Gt) do if(!Prev) do win.sendmessage(hwnd, 0x400+51, 2050, 0) else do(Exepath,"/O /S /L=" ++ Quote ++ Path ++ Prev ++ Ext ++ Quote) *keys {down} endif elseif(Ans == CtC) do clip.set(Cur) endif quit endif Prev = Name ++ Len endfor
How is it convenient to name files, especially if their order matters? Of course, with a counter, for example:
file-001
file-002
...
or
0001
0002
...
Therefore, all file names are ending with a certain quantity of numeric characters.
But at deleting, adding, or renaming files their numbering is disturbed. The script checks whether files are numbered sequentially, in ascending order, starting with 1. When the disturbance is found, the script allows either to go directly to the next file, or to copy the missing name to the clipboard. Before running the script the cursor should be placed on any file to be a "sample" to check others.
Why not use MultiRename Tool right away? Because the MultiRename Tool operation can take a great time for which Total Commander remains unavailable. For example, in one directory on my computer there are 24589 sequentially numbered files. If missing file has number, say, 24585, then there is no sense to rename all files.
Title | CheckDescCounter |
File Name | CheckDecCounter.txt |
Description | Check whether files are numbered in descending order |
Author | Vochomurka |
Parameters | ("%P", "%O", "%E") |
Plugins Called | win, file, miscplugin, clip |
Icon | |
Version | 1.4 |
Updated on | 18.04.2019 |
args Path, Name, Ext if(!Ext) Ext = "*" Ext = "." ++ Ext local hwnd = win.handle("c=TTOTAL_CMD") local Exepath = win.exepath(hwnd) local Len = length(Name) local mpDlgCaption = "CheckAscCounter Script" local mpIcon = "e:\Storage\Graphics\Icons\User\Incr.ico" local i, j, Char, mpDlgText, Prev, Cur local Quote = esc(?+\"+, ?+\+) local CtC = "&Copy to Clip" local Gt = "&Go to" for(i = Len; i > 0; i--) Char = Name[i - 1] if(not miscplugin.is_int(Char)) break endfor switch (i) case Len Char = "File name " ++ Name ++ Ext ++ " contains no counter" messagebox("ok error", Char, mpDlgCaption) quit case 0 Char = Name Name = "" break case else Char = Name[i, Len - 1] Name = Name[0, i - 1] endswitch local Digits = length(Char) local Total = repeat("0", Digits) for(i = eval(Char); i >= Total; i--) Len = fill(repeat("0", Digits), i) Cur = Path ++ Name ++ Len ++ Ext miscplugin.BalloonTip(1, "information", i, "timeout=5") if(!validpath(Cur)) do mpDlgText = "First missing file is '" ++ Cur ++ "'" local Ans = miscplugin.messagebox(1, Gt, CtC, "&Exit") if(Ans == Gt) do if(!Prev) do win.sendmessage(hwnd, 0x400+51, 2050, 0) else do(Exepath,"/O /S /L=" ++ Quote ++ Path ++ Prev ++ Ext ++ Quote) *keys {down} endif elseif(Ans == CtC) do clip.set(Cur) endif quit endif Prev = Name ++ Len endfor
The difference between previous script and this one is that the latter checks numbers in descending order:
...
file98
file99
or
...
9998
9999
Number consisting of nines is checked first.
All Scripts | Total Commander | TotalCmd.net | PowerPro |