9overflow
9overflow

Reputation: 728

Windows delete many files

i'm trying to delete many files in many sub-folders with random extensions, how can i do that? I have many encrypted files (ransomware), now i decrypted all files and i have a duplicate each file (30.000 files).

All encrypted files have a random name extensions with 6 characters like "namefile.pdf.123456" / "namefile.docx.ujyrtf"

Can you help me to write e script to delete all these files?

Are stored in folder and sub-folders

Maybe i can try to use a Multiple File Renamer to rename .jpg. to *.jpg.del and then delete all *.del by cmd, i don't know if i can do this.

I try to use CMD's like this and i type:

del *.jpg.*

but this command deleted all .jpg and all .jpg.*

Thank you

ATTENTION: there aren't any legit files in these folders. It is a folder data with mkv, jpg, doc, xls, etc. Documents, Video, Audio. Not application or Windows Folder or something like that. Don't use this SCRIPT on system partition, program folders because there may be legit files that would be deleted. Thanks Gerard

Upvotes: 0

Views: 196

Answers (1)

user7818749
user7818749

Reputation:

If all of the files have a 6 digit extension then we can use a findstr regex to delete them.

from cmd

@for /f "delims=" %i in ('dir /b /a-d *.????.* ^| findstr /r "\.[^\.][^\.][^\.][^\.][^\.][^\.]$"') do @echo del "%i"

or in a batch file:

@echo off
cd /d "C:\Path to files\to delete\"
for /f %%i "delims=" in ('dir /b /a-d *.????.* ^| findstr /r "\.[^\.][^\.][^\.][^\.][^\.][^\.]$"') do echo del "%%i"

This will just echo the result, you need to remove echo only once you can confirm that it does not delete un-intended files.

Upvotes: 1

Related Questions