Select files: how to select only n items?
Moderators: Hacker, petermad, Stefan2, white
Select files: how to select only n items?
Hi, i have a directory with 220 files and i want to select only the first 100 files, is there a plugin or Tc feature that let me select only the first 100 files ?, thanks
Re: Select files
I do not know any TC command that select directly n files.. But you can do it in 2 steps :sas2000 wrote:
Hi, i have a directory with 220 files and i want to select only the first 100 files, is there a plugin or Tc feature that let me select only the first 100 files ?, thanks
- Select all Files, Save Selection, filter to only keep first 100 lines.
- Load selection from file
select all files can be done using "cm_SelectAllFiles"
keep only first 100 lines :
you can use windows version of sed, awk, tcbl to filter only 100 first line and save to "100FirstFiles.txt"
Load selection from files "cm_LoadSelectionFromFile".
AutoHotkey: Select first n files, Select every n'th file
Here is such AHK script to
- Select the first n files from selected files:
(Selektiere die ersten n Dateien von den ausgewählten Dateien)
or
- Select every n'th file from selected files:
(Selektiere jede n'te Datei von den ausgewählten Dateien)
- Select the first n files from selected files:
(Selektiere die ersten n Dateien von den ausgewählten Dateien)
or
- Select every n'th file from selected files:
(Selektiere jede n'te Datei von den ausgewählten Dateien)
Code: Select all
;==============================================================================
;================================================================ P U R P O S E
;// D E S C R I P T I O N:
;// AHK-script for Total Commander to select files more exactly.
;// Stefan, v00.002, 2015-07-29
; v00.001, 2015-07-29: initial release
; v00.002, 2015-07-29: add query (MsgBox Execute?) before execution
; v00.003, ? todo ;-) : add GUI to choose wanted function, instead modify script by hand
;// http://ghisler.ch/board/viewtopic.php?p=298324#298324
;// AutoHotkey (AHK) is a free, open-source macro-creation and automation software. (http://ahkscript.org/)
;// Download the executable: http://ahkscript.org/download/ (portable zip, Unicode 32-bit, is just fine)
;// Unpack the archive, e.g. to "TC-Folder\Tools\AHK" or take care on the path yourself.
;// ------------------------------------------------------------------------------------
;// Integration into Total Commander:
;// Save this script with a new name, like DoXYZ.ahk ('.ahk' is mandatory)
;// Create a new usercmd.ini entry, like ('em_' is mandatory)
;// [em_RunAHK_DoXYZ]
;// Cmd=%Commander_Path%\Tools\AHK\AutoHotkey.exe
;// Para=%Commander_Path%\Tools\AHK\DoXYZ.ahk <perhaps an TC parameter here>
;// (see Help > Operation > User interface > Button bar > click on "Dialog box to change")
;// Use this new entry as button command "em_RunAHK_DoX",
;// or assign a keyboard shortcut to it (Configuration > Misc.)
;// Also, you can use this 'cmd' and 'para' commands on an button directly. (right click the button bar)
;==============================================================================
;============================================================== S E T T I N G S
;// S C R I P T S E T T I N G S:
#SingleInstance force
If not WinActive("ahk_class TTOTAL_CMD") {
MsgBox Please execute from within TC.
ExitApp
}
WinGet, vTCHandleID, ID, A
ControlGetFocus, vCurrFocus, ahk_id %vTCHandleID%
;// Store current clipboard content (to restore at the end):
vClipboardStorage := clipboard
;// TC-command: COPY SELECTED FILENAMES TO CLIPBOARD: (cm_CopyNamesToClip=2017)
SendMessage, 0x0433, 2017, , , ahk_id%vTCHandleID%
;==============================================================================
;====================================================================== U S E R
;// U S E R S E T T I N G S:
;// Choose a function to execute, disable all others:
;// (Wähle eine Funktion zur Ausführung aus, deaktiviere alle Anderen)
;// FUNCTION 1 - Select the first n files from selected files:
;// (Selektiere die ersten n Dateien von den ausgewählten Dateien)
vNewSelection := functionSelectAmountOfFiles(100)
;// FUNCTION 2 - Select every n'th file from selected files:
;//( Selektiere jede n'te Datei von den ausgewählten Dateien)
;vNewSelection := functionSelectEveryNthFile(5)
;==============================================================================
;============================================================== F U N C T I O N
;// T H E F U N C T I O N s':
;------------------------------------------------FUNCTION 1
functionSelectAmountOfFiles(vWantedAmount){
MsgBox ,1, Execute, Select %vWantedAmount% Files?
IfMsgBox Cancel
return
;//For Each Selected File Do:
Loop,parse, clipboard, `n, `r
{
;IF Loop-Index is greater than wanted-amount, break.
if(A_Index > vWantedAmount){
return %vNewSelection%
break
}else
;Else select this file:
vNewSelection .= A_LoopField . "`r`n"
}
}
;-------------------------------------------------------End
;------------------------------------------------FUNCTION 2
functionSelectEveryNthFile(vWantedAmount){
MsgBox ,1, Execute, Select Every %vWantedAmount% th File?
IfMsgBox Cancel
return
;//For Each Selected File Do:
Loop,parse, clipboard, `n, `r
{
;IF Loop-Index modulo wanted-step equal zero, select this file:
if(mod(A_Index,vWantedAmount) = 0)
vNewSelection .= A_LoopField . "`r`n"
}
return %vNewSelection%
}
;-------------------------------------------------------End
;==============================================================================
;================================================================== R E S U L T
;===== Work with our fabricated result
; MsgBox Result:`n%vNewSelection%
;
;// PASTE RESULT TO CLIPBOARD:
Clipboard = %vNewSelection%
;
;// TC-command: LOAD SELECTION FROM CLIPBOARD: (cm_LoadSelectionFromClip=2033)
SendMessage, 0x0433, 2033, , , ahk_id%vTCHandleID%
;==============================================================================
;================================================================ C L E A N U P
;// Restore last clipboard content:
Clipboard := vClipboardStorage
;// DONE
ExitApp
;==============================================================================
;======================================================================== E O F
Here is a shorter AHK script:
Roman
Code: Select all
WinActivate, ahk_class TTOTAL_CMD
WinWaitActive, ahk_class TTOTAL_CMD
; cm_GoToFirstFile
PostMessage, 1075, 2050
SendInput, {Insert 100}
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.