Top Menu

Technical help with a directory search issue, please ?

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.00 out of 5)

Hello everyone !

On my windows7 PC, I don’t know how to achieve something. Could I ask you ? :)

Emergency update : I’m working right now and I don’t have time to do more than this quick update, but I saw a lot of new comments, and I MUST write it at once : the comments engine eats antislashes, argh ! Please, use pastebin or equivalents for code lines, sorry I forgot about that issue when making the post ! T__T

I want to search a REAL HUGE location (inside an NTFS partition) and get a list, in order to remove them later, of all the directories that do NOT contain a .zip or a .rar file. Not in a sub-sub-subfolder, in its very current insides.
I’ll “save” a few directories, but the vast majority of them, the ones that don’t directly contain a zip/rar, will be deleted by me.

Those folders also contain other files, but the only criteria is the presence of a .zip and/or .rar file.
If there’s none of those two archive types, then the folder must be shown to me (either as a browsable list, or as a text outputted list that I can use – for deletions – later).

Would you know how to do it ? Please ?
The default Windows search isn’t helpful, but maybe Total Commander, or any other utility (I may install programs if needed, and I can create batch files), might help ?
I would even be ready to boot a Linux liveCD and write+run a bash script after having mounted the partition, if Linux is the only one that can get it done.

Thanks if you can share your ideas on this, it’s to prepare my next gigatorrent, I don’t want to have to browse thousands of folders to remove all unnecessary empty folders that could increase clutter :)

Hello! This post is getting on years, so here's a friendly mention... If all the links are dead, you may try using
Pick exclusively a precise file with a keyword search, or bulk leech like a madman, it's quick and easy :)

Leave a Reply

newest oldest most voted

chek if you have remuved the hiden files option then go and see agen

Oliver AKA The Admin

… what ?


I'm pretty fluent in bash scripting (read linux shell scripts) if you want. Post a sample with the same directory and file structure and I'll test it.

Oliver AKA The Admin

Ah, well, basically, the structure would be
0 mangas
1 CGs
2 Picture packs
3 Vids
4 Animated gifs

Inside 0 mangas, for instance, extracts :
> contents >
Yamatogawa, Aqua Bless <a href="http:// (” target=”_blank”> <a href="http://(” target=”_blank”>( [English]
Yamatogawa, canvas [English] <a href="http:// (” target=”_blank”> <a href="http://(” target=”_blank”>(
Yamatogawa, Witchcraft <a href="http:// (” target=”_blank”> <a href="http://(” target=”_blank”>( (English, Uncensored Tank)

Inside Yamatogawa, Aqua Bless <a href="http:// (” target=”_blank”> <a href="http://(” target=”_blank”>( [English]
> contents >
Yamatogawa,_Aqua_Bless_ <a href="http:// (” target=”_blank”> <a href="http://(” target=”_blank”>(
Preview Pics

The latter, Preview pics, is a folder with, inside 000.jpg, 0xx.jpg, 0yy.jpg, the images that served as preview pics for this post

It can be many other things, there are plenty of reasons, for me, to keep subfolders not containing zips/rars, for instance additional information, bonus pics, private files from people with whom I was in relation and that must not become public.

Some rare subfolders without archives are legit (like the top directories), but most of them aren't, and I need their list for scrutiny and removal :)


Do you know the C# language?
I just made a simple code (Console Application) for your needs, you can compile it using Visual Studio Express. It's my way of saying thanks for all the good hentai :D

using System;
using System.IO;
using System.Linq;
using System.Text;

public class Test
public static void Main()
const string folderPath = @"C:Coding"; // Replace according to your needs

const string outputListFilePath = @"C:TEMPoutput.txt"; // Replace according to your needs

var allSubdirs = new DirectoryInfo(folderPath).GetDirectories();
var wantedDirs = allSubdirs.Where(d => d.GetFiles().Any(f => f.Extension == ".rar" || f.Extension == ".zip"));
var wantedDirsPaths = wantedDirs.Select(d => d.FullName).ToArray();

File.WriteAllLines(outputListFilePath, wantedDirsPaths, Encoding.Default);

Oliver AKA The Admin

The farest I went into coding was Python (fun, although I should have gone at the point where it would become useful… I didn't), but I wouldn't mind installing a C compiler, why not, as long as it does the job ^^

I'll see if there are easier answers by the next two days, and otherwise, on to C ! ^^

Thank you Fellow Lurker :)


From what i See, your code would return all the folders containing a zip or rar file, but Oliver is looking for the folders without these type of files. I don't have my C# environment here, but I suppose it should be GetFiles().Except() instead of GetFiles().Any().


I would use Everything for that Let it build its search index for a moment after installing it, then you should be able to search. It also supports a subset of regex, if you're familiar with it.


First Time Posting long time Lurker, I use this program alot when I have to remove a crap load of folder but need to st a parameter to make sure I dont delete certain folders.
FREE Windows program to remove empty folders

Under the Setting Tab where it says "Ignore these files" Just type in the differnet typeof files you want it to delete even if it isnt empty (*.jpg, *.png, etc) and it will treat those folders as empty as well

Works up to windows 8.1 (tested)


With Unix commands I would try a list of directories, then get a list of zip/rar files. Then compare them using something like vimdiff.

# find . -type d | sort >> directories.txt

# find . -name ‘*.zip’ -o -name ‘*.rar’ | sort >> files.txt

# vimdiff directories.txt files.txt

Or with those two files (in perl) just build a hash with directories as keys, and remove matches with a zip or rar.


«find» can be used to do all of the above PLUS deleting the unwanted directories in just ONE command. And one may install e.g. cygwin in to have it at one's disposal at all time without needing to boot from some live CD


He's using Windows, therefore also DOS.
Very simple. Use this example to search from your partition, whatever driveletter it uses.

Open a Command prompt and it will show you this:

Type this followed by Enter after each line:
And it will show you this:

If you know your partitition driveletter then just type its driveletter at the command prompt followed by the enter key and search from its root. Example: C:Usersyour_account_username>F:
Now type this:
dir *.zip /s /oe >> Directories.txt

What it will do is search for all zip files on your partition or driveletter, and order them by their extension and that output will be written onto a textfile which you can use as reference to discriminate folders without .zip files (or .rar if you change the syntax to *.rar).

Here's an example output:
Volume Label is SystemHDD
Volume serial number is: A861-46FB

Directorio de C:Usersyour_account_usernameAppDataLocalLowAdobeAcrobat10.0

13/02/2013 05:47 p.m. 38,893
1 archivos 38,893 bytes

Directorio de C:Usersyour_account_usernameAppDataRoamingAzureuspluginsaefeatman_v

10/02/2013 02:36 p.m. 54,691
1 archivos 54,691 bytes

Directorio de C:Usersyour_account_usernameAppDataRoamingAzureuspluginsazlocprov

29/10/2013 02:38 a.m. 1,304,128
20/09/2013 04:08 a.m. 1,294,543
2 archivos 2,598,671 bytes

Directorio de C:Usersyour_account_usernameAppDataRoamingAzureuspluginsaznettor

09/04/2014 02:01 p.m. 1,606,588
1 archivos 1,606,588 bytes

Directorio de C:Usersyour_account_usernameAppDataRoamingAzureuspluginsazutp

10/02/2013 02:36 p.m. 903,070
26/06/2013 12:08 a.m. 1,005,705
15/05/2013 04:34 a.m. 1,005,465
05/03/2014 04:09 p.m. 185,781
20/04/2014 03:25 a.m. 185,738
10/02/2013 02:36 p.m. 902,863

Since this effectively excludes any directory without a zip file inside it and also tells you its path it is quite easy to use this to determine what you need, since those directories are to be kept and all the others wouls not.


There's an error above:
When you type: cd.. both instances use dots not commas. My bad.


For some reason the comment box doesn't allow the inverted slash character to show, so the above example could be wrongly displayed. There are inverted slashes after the : and in between the Users and your_username_account, etc. Be wary of that.


Ok after some work i have this batch for you (just put the code in a .bat)
Is going to search recursively, beginning where the batch is executed, and the output is and file (in the same directory) with all the directories that NOT have any zip or rar.

You can test it and tell me if i forgot some conditions.

PD: this maybe is going to take a while because is going to search EVERYWHERE starting in the directory where you execute the batch.

@echo off
setlocal enableextensions enabledelayedexpansion

if exist FoldersWithoutZips.txt del FoldersWithoutZips.txt

set root=%CD%
set subfolder=%CD%
set haszips=0

for /R %root% %%x in (.) do (

set subfolder=%%x
set subfolder=!subfolder:~0,-1!

echo SEARCHING ON: !subfolder!

for /F %%f in ('dir /b "!subfolder!*.zip"') do ( set haszips = 1)
for /F %%g in ('dir /b "!subfolder!*.rar"') do ( set haszips = 1)

if !haszips! == 0 ( echo !subfolder! >> FoldersWithoutZips.txt )

set /p input= Press ENTER key…


You are right the backslashes XD. Here the link to pastebin


From Linux it is really easy. First of all backup. Then copy the folloging lines into a file called; put the file into the main folder (i.e., together with the subfolders you want to search through).
Please do mind that it will automatically move all folders which have no zip or rar file inside into a folder called nozips outside your main folder; a text file with names of moved dirs will also be created.

mkdir ../nozips
for DIR in */; do
if [ "$(ls $DIR*.{zip,rar} | wc -l)" -ge "1" ]; then
echo ""
# change mv with cp to copy the folders, not move them
mv $DIR ../nozips
ls ../nozips > ../nozips.txt
exit 0


To use the script you must also do in terminal: chmod +x (so that it can be executed)

John Morgan
John Morgan

I would suggest deleting the files you don’t want to keep and then delete empty directories, repeating until there are no empty directories to keep.

See for an explanation of how to remove empty directories.


If you want just a “huge” list you can give wList a shot:

Highly customizable for your needs.


Here's something I wrote in Python3:

You can uncomment some of the lines there if you need to see in which directories those archive files reside (and their actual filename). I did not test it in Python 2, but it _probably_ should work without changing anything.