20

I have a Windows Explorer folder that contains files that are named file0001, file0002 etc. I would like to select and open only the files with an even number in the name.

My approach is the following. I enlarged the icons and made the Windows Explorer window smaller, such that the files are shown in 2 columns:

file0001 file0002

file0003 file0004

...

Is there a way to select the second column here? Or is there another (fast) way to do this.

5
  • 1
    I assume the files are sorted by name?
    – Dave
    Jan 15, 2016 at 13:13
  • 1
    After selecting the second column, what are you planning to do with the files?
    – doenoe
    Jan 15, 2016 at 13:17
  • 1
    How long is this list? IF the list fits on your screen without scrolling, then a dreadful work around is to use AutoHotKey, where you move the mouse N pixels down and click, since the height of each item in the list is the same (in details view)
    – Dave
    Jan 15, 2016 at 13:18
  • - @David: Yes. - Frank Thomas: Indeed. - doenoe: Open them in Windows Photo Viewer. - Dave: Nice trick, but the list can be quite long.
    – Karlo
    Jan 15, 2016 at 13:27
  • 5
    Use powershell Get-ChildItem | Where-Object {$_.Name -match "[0,2,4,6,8]$"} will list all files ending with an even number, then you can pipe this list to some other command (eg. I would use move to move them to another directory)
    – Zina
    Jan 15, 2016 at 13:58

3 Answers 3

21

Yes, this is possible (albeit hacky) if your files are named as you describe you can size the File Explorer Window to organise your files into columns (as long as you don't miss any files out so the 'second column' is always even). What you can then do is select every other file, depending on where you start drag and drop (and thus selecting odd or even).

If you View by icon (I chose large icon) and change the width of Windows Explorer so it only has "2 columns" , then you can hold down CTRL and use left click and drag with the mouse, downwards (from just above the first icon in the "second column" (in the white space)).

As an aside, depending on how many columns you have, you could also select every third file or fourth file etc

I've just done it, and it will automatically scroll as well.

You can even then maximise Windows Explorer (File Explorer) and the selection will kept.

2
  • Indeed. My mistake was that I started by clicking on the first file. You have to start by clicking on the white background next to it instead.
    – Karlo
    Jan 15, 2016 at 13:30
  • 4
    It's worth noting this will only work if the files are consecutive, if a number is missing the order well mess up (+1 for simplicity though, and I realise the question wanted this as the answer)
    – Jonno
    Jan 15, 2016 at 13:40
4

The window resizing trick shared by Dave works great for the majority of cases. In my case, I had over 25,000 images extracted from a video and I needed every other image deleted. Waiting for the drag to select all the files took longer than I was willing to wait!

My files were named in the same pattern as yours (file0001.jpg, file0002.jpg, etc). Since I wanted every other file, I knew the files I wanted would either end in a 0,2,4,6, or 8.

To select the relevant files, I entered *0.jpg OR *2.jpg OR *4.jpg OR *6.jpg OR *8.jpg in the search box of windows explorer while I was in the folder with all my images. I then pressed Ctrl+A to select all, then hit delete and I was done!

This trick will only work to select every x numbered items where x is a factor of 10 (so 1,2,5, or 10) but the click and drag should work for any interval.

So this method is fastest but the click and drag method is more flexible. Choose whichever one best suits your needs.

2
  • This is a good solution
    – Dave
    Jul 21, 2018 at 16:45
  • This is a very good hit. I did not even know that Windows Explorer search was able to do that logic filtering. Thank you for the hint. Jul 9, 2020 at 14:53
0

to separate off such files, rather than just selecting them as described by other posters:

install cygwin from cygwin.org

make sure you select perl to be installed during the installation process

open a cygwin shell

copy the entire contents of your target directory to somewhere safe

cd to your directory using cd /cygdrive/c/path/to/your/dir

This command will delete all filenames which are not even from your target dir, so I repeat, ensure you have backed up first. It looks for consecutive runs of numbers, eg file864.ext to calculate if it's odd or even. if your files are numbered any other way eg file3xyb345, then this won't work.

type

perl -e 'while (<*>) { ($num) = $_ =~/(\d+)/; `rm "$_"` if $num % 2 }'

You are now left with only even numbered files in that dir. the rest are gone.

Pingers.

4
  • 5
    Seems like a lot of work for this, particularly considering you could ... just install perl in windows, or use powershell, or even CMD/batch, if programmatic solution were desired.
    – Joe
    Jan 15, 2016 at 19:23
  • 1
    Yes, I slightly mis-read the q on this one :)
    – Pingers
    Jan 15, 2016 at 23:08
  • @Pingers This was not really what I was looking for, but thanks for sharing this method.
    – Karlo
    Jan 18, 2016 at 7:46
  • 3
    Not the easiest way to go for this simple criterion, but if you do have cygwin installed, then there are all sorts of things you can do (relatively easily) just in the bash shell it provides to sub-select files in almost any way imaginable - for cases far more complex than this one.
    – Joe
    Jan 18, 2016 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.