Selection order

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Look,
your 'select' button should receive %P%N and: 1) add filename to end of cache, 2) mark file in TC,
your 'process' button should receive %L and: 1) count number N of files in %L, 2) take last N items from cache for processing.

So it will always process only latest selected files.

And you will only need to focus C.pdf, press shortcut, focus B.pdf, press shortcut, focus D.pdf, press shortcut and focus A.pdf and press shortcut and then execute processing.


As an option, you can open last list in e.g. in text editor before processing so you will always see what exactly will be processed, and even change order by swapping lines (there should be one filename per line, it is easy then to build single command line from such list).

You know, you have quite specific task, I don't remember any other such request for years, so your task seems to be the only requiring selection order...
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

I see now. It is possible with %P%N. When selection is restarted, since %L comes with 1, no item is considered in the cache. Good idea.
As an option, you can open last list in e.g. in text editor before processing so you will always see what exactly will be processed, and even change order by swapping lines (there should be one filename per line, it is easy then to build single command line from such list).
Another good idea.
You know, you have quite specific task, I don't remember any other such request for years, so your task seems to be the only requiring selection order...
It is interesting. Most of the editors, joiners, players, .. etc. support the file order. This should not be a specific task...

Actually, upto now, there is no support for the custom file order for the %P%S by forum friends. You seems right...
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

MVV,

I looked at the TCFS2, it seems wonderfull (like sudo and sudo64). But it is a little bit complicated (like a new programming language). However, it is possible to read, understand and use.

Until to understand fully it, can you give an example in order to focus to cmd line and in order to send the script full path. What should "hwnd" be?
meisl
Member
Member
Posts: 171
Joined: 2013-12-17, 15:30 UTC

Post by *meisl »

I may have missed something, but hasn't white already given the hint for a very nice and easy solution?
white wrote:Do you know that in the multi-rename tool you can sort the list, drag around lines in the list and even delete lines from the list?
So here's how I'd do
HBB wrote:Assume 4 files will be processed: 1) A.pdf 2) B.pdf 3) C.pdf 4) D.pdf

Desired order: 1) C.pdf 2) B.pdf 3) D.pdf 4) A.pdf
1) Select all four, A.pdf, B.pdf, C.pdf, D.pdf (order doesn't matter yet, could also come from Find files)

2) Ctrl-M (multi-rename tool), no actual renaming but add full path: file name="[=tc.path][N]", extension="[E]", Search for RegEx "^(.).\", Replace by "$1:\" (fixes drive prefix, make sure you have "RegEx" checked)

3) change order as desired by dragging lines in the list. For this example: drag C.pdf to top, then A.pdf to bottom.

4) now click the little button to the right of the "Upper/lowercase" dropdown and below the other little button with "?" on it

5) Select "Configure editor..." and specify the "execute" script. For example C:\test.bat with the following contents:

Code: Select all

@type %1
pause
6) click button from 4) again and this time select "Edit names..." - voilà :)

Contrary to the "focus & Shift+Ctrl+Enter" proposal, this has the advantage of a clear (and readable) visual representation of the actual order of files, which I think is way better than having it implicit (as by having TC "remember" which was selected when).
It's also easy as pie to adjust the order in case you make a mistake. You don't have to start all over.
The script receives the path to a temporary file with the list in it as 1st parameter, so there's no need to "clear the cache".
You may of course save these settings for re-use (F2).
However, this does not include the "editor" (step 5)). To revert to normal notepad, "Configure Editor..."="c:\windows\notepad.exe".
Last edited by meisl on 2014-02-21, 20:14 UTC, edited 1 time in total.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

HBB,
You don't need TCFS2 with my select/process actions. You may only need TCFS2 /ef "send(`{INS}`)" in order to mark focused file with Insert. However TC must be active for this command to work (it generates keyboard input events that may only be received by active window).

However if you want to build command in TC command line, it is much faster to send Ctrl+Shift+Enter using TCFS2 /ef "send(`^+{ENTER}`)" in order to append focused file to command. This command may be added as buttonbar button or em-command with another shortcut.

Anyway, hwnd is an optional parameter for TC dialog windows, you may omit it.


meisl,
It is quite uncomfortable to switch MRT editor every time when you need to perform this specific task...
meisl
Member
Member
Posts: 171
Joined: 2013-12-17, 15:30 UTC

Post by *meisl »

MVV wrote:It is quite uncomfortable to switch MRT editor every time when you need to perform this specific task...
Well, if I were to perform it more often then I'd set of course once some reasonable editor like EditPlus or notepad2 from which I would then launch the "execute script".
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

MVV, thanks

TCFS2 /ef "send(`{RIGHT}Path\To\Script.exe`)" works successfully.

EDIT> with a small problem. the letter i and slashes are converted to other characters??

EDIT2> quotations surrounding script path are eaten. Is there a way to send characters as it is?

EDIT3> I found it : '~' character.

EDIT4> TCFS2 /ef "send(`{RIGHT}{DQ}Path~\To~\Scr~ipt.exe{DQ} `)" now works successfully.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

HBB,
The problem of keyboard events is that they are layout and capslock-dependent (so will type e.g. Russian characters in RU layout). That's why ~ was added for sending exact Unicode characters instead, and you can use it with round brackets in following way:

Code: Select all

TCFS2 /ef "send(`{RIGHT}{DQ}~(X:\Path\To\Script.exe){DQ} `)"
meisl
Member
Member
Posts: 171
Joined: 2013-12-17, 15:30 UTC

Post by *meisl »

HBB, have you tried my approach?

Plz note that it's NOT about actual renaming, it just uses the MRT for
a) comfortably putting a list of files into some arbitrary order and then
b) passing that list to some program for further processing.

...which, as such, is in principle and IMHO a far better paradigm than what you're trying to do by "recording actions of selection", in some way or another.
You have pointed out yourself the drawbacks of that approach (-> "cache", when to reset it, etc ...).
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

meisl,

I tried it, but I got this message : error, could not rename the files shown in bold

Probably, I have a mistake. However, this method may work, but is not easy than the others.

Thank you for the detailed instructions (also White for the hint).

Regards
meisl
Member
Member
Posts: 171
Joined: 2013-12-17, 15:30 UTC

Post by *meisl »

HBB,
you've probably clicked the "Start!" button, judging from the error message.

Again: do NOT click the "Start!" button - it's NOT about doing an actual renaming!
(the button I'm referring to in pt 4) has a folder-like symbol on it; it is the only button in the MRT dialog with an image on it rather than a letter or phrase)
HBB wrote:However, this method may work, but is not easy than the others.
Ooops...? In fact it does look by far easier and also more intuitive and straight-forward - at least to me...
My description is admittedly rather long and detailed, but you need to actually try it up to the end in order to get a feeling of how usable it really is.
To be clear: I, myself, did actually try both of course, mine and the "repeated focus + Shift-Ctrl-Enter".

Could you explain why exactly you don't agree on that :?:

I mean for example in terms of the number of
- keystrokes/mouse clicks,
- additional intermediate scripts/APIs to use
- additional intermediate files like .ion and/or .bbs to use (obviously: less is better, as with the 2 previous pts),
- ways to populate the list in the first place (here: more = better)
- and having an actually readable/usable visual feedback of what order your list is currently in.

(note that you can even remove single files from the list easily, as white had pointed out before as well)
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

As a result, two methods seem easy/regular to me:

Method 1 : This method is suggested by HolgerK (with MVV's improvements):

> Run command : TCFS2 /ef "send(`{RIGHT}{DQ}~(X:\Path\To\Script.exe){DQ} `)"
> Select 1. file by Control+Shift+Enter
> Select 2. file by Control+Shift+Enter
> :
> To execute, just press Enter

Method 2 : This method is suggested by MVV (with my improvements):

> Select 1. file, then press the button which runs the below script.
> Select 2. file, then press the button which runs the below script.
> :
> To execute, just press the same button again without selecting a new file (or removing a selected one)

[EDIT] Parameters of the button : %P%S (Sorry, I forgot to mention)

Script :

Set FSO=WScript.CreateObject("Scripting.FileSystemObject")

Set CacheFileObject=CreateObject("Scripting.Dictionary")
CacheFilePath=FSO.GetSpecialFolder(2).Path+"\OrderedFileListToSendToAScriptInTotalCmd.txt"
If FSO.FileExists(CacheFilePath) Then
With FSO.OpenTextFile(CacheFilePath)
Do While .AtEndOfStream <> True
FilePath=Trim(.ReadLine)
If FilePath <> "" Then CacheFileObject.Add LCase(FilePath),""
Loop
End With
End If

For Index=0 To WScript.Arguments.Count-1
FilePath=Trim(WScript.Arguments(Index))
If CacheFileObject.Exists(LCase(FilePath)) Then
CacheFileObject(LCase(FilePath))=FilePath
Else
CacheFileObject.Add LCase(FilePath),FilePath
Changed=True
End If
Next

Keys=CacheFileObject.Keys
For Index=0 To Ubound(Keys): Key=Keys(Index)
If CacheFileObject(Key) = "" Then
CacheFileObject.Remove Key
Changed=True
End If
Next

Files=CacheFileObject.Items
For Index=LBound(Files) To UBound(Files)
CachFileContent=CachFileContent+Files(Index)+vbCrLf
Count=Count+1
Next

If Changed Then
FSO.OpenTextFile(CacheFilePath,2,True).Write CachFileContent
Else
If Count=1 Then WScript.Quit
RetVal=MsgBox(CachFileContent)
' Execution is here
If FSO.FileExists(CacheFilePath) Then FSO.DeleteFile CacheFilePath, True
End If
meisl
Member
Member
Posts: 171
Joined: 2013-12-17, 15:30 UTC

Post by *meisl »

Well, ok. I've tried my best.
No offence & cheers :)
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

Currently, there is a problem while using %S. TC assumes that the file under the cursor is selected even if it is not selected (I mean highlighted). This may not be problem for a file joiner script like above one (requires at least two files). But, it creates problem for other scripts/programs which need the highlighted files.

I searched the forum, I found a few discussion on it (There are some suggestions like %H to skip it). Is there a way to distinguish it in parameters (I asked because I sometimes miss somethings)?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If there are no selected files, focused one is always treated as selected for all operations that require some files to be taken. It was always so in TC.
Post Reply