AHK: How To Delete Every Other File in a Folder

STEP 1: Make a new AutoHotkey file. Not sure how to do that? Click here.

STEP 2: Right click your new AutoHotKey Script → Edit Script.

STEP 3: Copy and paste this text into the body.

Var = 8071
Loop, 100
FileDelete, C:\Users\Desktop\Sentient Webcam\IMG_%Var%.jpg

STEP 4: Go to the folder with all the files in it, and copy the file path so the computer knows where to look. Paste that in place of the red text in the script.


STEP 5: Change the variable (the green text in the script) to whatever number the name of your file ends with.

*CAUTION: For this to work, the files need to be numbered sequentially in increments of one.*

STEP 6: Save the AutoHotkey script → Close → Right click the script → Run Script

Anatomy of a Script:

Every now and then, I make stop-motion movies featuring technology misbehaving. Like this.


Generally I start by convincing a friend of mine, let’s call her Click-Happy, to take a series of photos while I re-position things in between shots. Inevitably, I end up with a kajillion pictures when I only need about 30.

This is how the creatively named Delete-Every-Other-File-In-a-Folder-Script, AKA DEOFIFS, came into being. I set the code to cut every other jpg and instantaneously halve my photo set.

I’m gonna be honest, I can think of no other applications of this script. Unless maybe you really wanted to screw with someone’s head by downloading this onto their computer and assigning it to a Hotkey, so every time they press the letter H, half their files go missing. That would be evil though. Please don’t do that.


Based loosely on the Awesome-Shit-Ton-Of-Files-Making-Script already posted, DEOFIFS uses a variable and a loop paired with the FileDelete function in AutoHotkeys.

The only additions here are:

FileDelete, FileToDelete


var+= theNumberToAddToVariable

Keep in mind for this script, you can adjust the variable increments to delete fewer of your files by having it only delete every third or fourth file.


Tagged , , , , , ,
%d bloggers like this: