Select every 7th file...

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Select every 7th file...

Post by *DaveCmd »

I have a about 2200 JPG files named sequentially, e.g: file0000.jpg, file0001.jpg, file0002.jpg, file0003.jpg, etc.
I would like to select every 7th file so that I can delete them.
Is there a way to do this with RegEx or is there a Total Commander script available? I have looked and I have not been able to locate one.

Thanks for your help!

Dave
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

AutoHotkey: select every nth File/ select only file number

Post by *Stefan2 »

Hi and welcome Dave.

We can do that by utilizing a AutoHotkey script, which will do:
-- (first YOU should select some or all files)
- TC-command: COPY SELECTED FILENAMES TO CLIPBOARD: (cm_CopyNamesToClip=2017)
- do the wanted counting, and put calculated Lines back on clipboard
- TC-command: LOAD SELECTION FROM CLIPBOARD: (cm_LoadSelectionFromClip=2033)





See f.ex:
viewtopic.php?t=42481&highlight=select



Somehow related:
viewtopic.php?t=43913&highlight=select



There are other tools mentioned too.


HTH?
User avatar
Vochomurka
Power Member
Power Member
Posts: 814
Joined: 2005-09-14, 22:19 UTC
Location: Russia
Contact:

Post by *Vochomurka »

Single user license #329241
PowerPro scripts for Total Commander
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

DaveCmd,
AutoHotkey script:

Code: Select all

#NoEnv

FileCount = 2200
EveryNthFile = 7

#IfWinActive, ahk_class TTOTAL_CMD
F10::
	DownCount := EveryNthFile - 1
	i = %EveryNthFile%
	While i <= FileCount
	{
		SendInput, {Down %DownCount%}{Insert}
		i += EveryNthFile
	}
Return
Save as SelectEveryNthFile.ahk. Adjust FileCount and EveryNthFile as necessary. Run it. Place the cursor on the first JPG file and press F10. Magic.

HTH
Roman
Last edited by Hacker on 2017-07-19, 10:32 UTC, edited 1 time in total.
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.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

first class, Roman.


Perhaps from interest:
For me, "I++" makes more sense for counting than the "I+=EveryNthFile"





 
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

Stefan2 wrote:first class, Roman.

Perhaps from interest:
For me, "I++" makes more sense for counting than the "I+=EveryNthFile"

 
@Stefan2
For me the counter i count file you (will) pass and not step of the loop, Roman is really premium Class.

@Roman
For me, initialization should be i = EveryNthFile instead of i = 1 to not send any key if you do not have enough file to {down} / {Insert} specially at the end....
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Stefan2,
Thank you but I don't think such a simple script deserves so much praise. :D
For me, "I++" makes more sense for counting than the "I+=EveryNthFile"
If you have 2200 JPGs and in each iteration you "process" 7 (move down six times, select one), you don't want to have 2200 iterations (= 2200 x 7 files) but 2200 / 7 iterations.

nsp,
initialization should be i = EveryNthFile instead of i = 1 to not send any key if you do not have enough file to {down} / {Insert} specially at the end
True, edited, thank you.

Roman
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.
User avatar
DaveCmd
Junior Member
Junior Member
Posts: 15
Joined: 2017-07-18, 15:36 UTC

Post by *DaveCmd »

Roman, Stefan, Vochomurka,
Awesome!
In the end I went the AHK route with edits, and It works!
Thanks for helping me with this. You added a new powerful tool to my arsenal.

Dave
g200
Junior Member
Junior Member
Posts: 32
Joined: 2015-10-08, 15:18 UTC

Re: AutoHotkey: select every nth File/ select only file number

Post by *g200 »

Hacker wrote: 2017-07-18, 16:46 UTC Save as SelectEveryNthFile.ahk. Adjust FileCount and EveryNthFile as necessary. Run it. Place the cursor on the first JPG file and press F10. Magic.
Am I missing something?
Created txt file with the script. Changed the number of files and every n-th file to select. Saved as .ahk file,
TC Mark > copy selected files to clipboard > load selection from file > SelectEveryNthFile.ahk > F10 to run > no selected files

Please help.
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: AutoHotkey: select every nth File/ select only file number

Post by *Stefan2 »

g200 wrote: 2022-10-21, 17:59 UTC
Am I missing something?

TC Mark > copy selected files to clipboard > load selection from file > SelectEveryNthFile.ahk > F10 to run > no selected files


> copy selected files to clipboard
> load selection from file

? hmm, but irrelevant for the AHK script.


- - -

> SelectEveryNthFile.ahk > F10 to run > no selected files

You have AutoHotkey installed?
Which version?






 
g200
Junior Member
Junior Member
Posts: 32
Joined: 2015-10-08, 15:18 UTC

Re: Select every 7th file...

Post by *g200 »

I don't have AutoHotkey. Downloaded AutoHotkey_1.1.34.04 and unpacked it. Do I need to run AutoHotkeyU64.exe to start the app?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Select every 7th file...

Post by *Horst.Epp »

g200 wrote: 2022-10-21, 18:59 UTC I don't have AutoHotkey. Downloaded AutoHotkey_1.1.34.04 and unpacked it. Do I need to run AutoHotkeyU64.exe to start the app?
You should not unpack, just install it.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Select every 7th file...

Post by *Stefan2 »

g200 wrote: 2022-10-21, 18:59 UTC I don't have AutoHotkey. Downloaded AutoHotkey_1.1.34.04 and unpacked it. Do I need to run AutoHotkeyU64.exe to start the app?

"D:\rive\Path to\AHK\AutoHotkey.exe" "D:\rive\Path to\your script.ahk"


If you utilize AutoHotkeyU64.exe or AutoHotkeyU32.exe or AutoHotkey.exe doesn't matter here.
If you have AutoHotkey installed, you can just double click the script.ahk file from every where.



more >>> viewtopic.php?p=350976#p350976




 
g200
Junior Member
Junior Member
Posts: 32
Joined: 2015-10-08, 15:18 UTC

Re: Select every 7th file...

Post by *g200 »

It looks like I downloaded the wrong file. AutoHotkey_1.1.34.04.zip

Thanks.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Select every 7th file...

Post by *Horst.Epp »

g200 wrote: 2022-10-21, 20:48 UTC It looks like I downloaded the wrong file. AutoHotkey_1.1.34.04.zip

Thanks.
Yes, download the installer.
Its small and doesn't harm your system.
You then can compile scripts with the context menu of ahk files
or start scripts by double click.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Post Reply