output end-level empty subfolders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

output end-level empty subfolders

#1 Post by taherkhani » 10 Dec 2012 07:43

how can i list my empty folders and subfolders in a main folder?

supose that my main folder is:

f:\ta\a\main\sub1\
f:\ta\a\main\sub2\subsub1
f:\ta\a\main\sub3\subsub2
f:\ta\a\main\sub4\subsub3\subsubsub1
f:\ta\a\main\sub5\subsub4\subsubsub1

supose that folder 'main' is completely empty.

i want a program that output a list of end-level empty subfolders, i mean in this example,
output these .txt file:

f:\ta\a\main\sub1\
f:\ta\a\main\sub2\subsub1
f:\ta\a\main\sub3\subsub2
f:\ta\a\main\sub4\subsub3\subsubsub1
f:\ta\a\main\sub5\subsub4\subsubsub1

and don't output these line:

f:\ta\a\main
f:\ta\a\main\sub2
f:\ta\a\main\sub3
f:\ta\a\main\sub4
f:\ta\a\main\sub4\subsub3
f:\ta\a\main\sub5
f:\ta\a\main\sub5\subsub4

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#2 Post by taherkhani » 10 Dec 2012 14:15

this program can job that, but don't work for unicode character:

http://simonwai.com/bin/EmptyFolderNuker.exe

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: output end-level empty subfolders

#3 Post by abc0502 » 10 Dec 2012 17:44

The problem is in the cmd window, it can't display unicode character, try to out-put the result to a txt file and open the file after it is done, maybe that might work.

Edited:
This work for me

Code: Select all

@ECHO OFF
Del /F /Q "log.log" 2>nul
For /F "delims=" %%A in ('DIR /B /S "*.*"') Do echo %%A>>log.log
log.log

Put it in the main folder

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#4 Post by taherkhani » 11 Dec 2012 00:30

@abc0502,
thanks, but my output isn't that i'm goal. I upload log file:

http://letitbit.net/download/38559.3ecbb4bfb7a29b5aa42071b98829/log.log.html

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: output end-level empty subfolders

#5 Post by abc0502 » 11 Dec 2012 01:23

sorry, this website is annoying, upload to any other website. and explain what exactly you mean.

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#6 Post by taherkhani » 11 Dec 2012 02:33

log file:
http://depositfiles.com/files/lo3etp4yc

i want output only empty folders that even have not any folder in it.

supose I have:

main
|_subfol
|_subsubfol

and main is empty folder, itmeans that subfol and subsubfol are also empty, but main contain a foder and subfol contain a folder too,
I have just the path empty folders that contain anything.
In this example i want output :

main\subfol\subsubfol

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: output end-level empty subfolders

#7 Post by abc0502 » 11 Dec 2012 02:41

Sorry, do you mean you just want to display the last folder in the tree of all folders.
and empty means that the folder must not contain any other sub-folders ?

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#8 Post by taherkhani » 11 Dec 2012 02:53

Sorry, do you mean you just want to display the last folder in the tree of all folders.
and empty means that the folder must not contain any other sub-folders ?


Exactly.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: output end-level empty subfolders

#9 Post by foxidrive » 11 Dec 2012 03:33

Do you want to display them or do you want to delete them?

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#10 Post by taherkhani » 11 Dec 2012 03:43

@foxidrive
Do you want to display them or do you want to delete them?


I want display them too a .txt file.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: output end-level empty subfolders

#11 Post by foxidrive » 11 Dec 2012 04:08

See if this works for you:

Code: Select all

@echo off
for /d /r %%a in (*) do (
dir /b /a "%%a" 2>nul | find /c /v "" | findstr "^0$" >nul && >> file.txt echo %%a
)
pause

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: output end-level empty subfolders

#12 Post by abc0502 » 11 Dec 2012 04:11

nice one Foxidrive, mine reached 10 lines and didn't complete yet :lol:

taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

Re: output end-level empty subfolders

#13 Post by taherkhani » 11 Dec 2012 06:48

See if this works for you:

Code:
@echo off
for /d /r %%a in (*) do (
dir /b /a "%%a" 2>nul | find /c /v "" | findstr "^0$" >nul && >> file.txt echo %%a
)
pause


it's work, but not for unicode, if i run that for unicode, output ? character instead of any unicode character like this:

D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\358.30 ?????? ??? (1)
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\358.54 ??? ??? ????? ???????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\359.38 ?????? ?????? ????? (???????)
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\359.39 ??????? ??????? ???????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\359.40 ?????? ??????? ???????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\359.54 ????? 2
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\450.7 ???? ??? ???? ???? ????? 3
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\461.3 ???? ??? ??????? ??????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\482.8 ????? 3(???????)
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\490.6 ?????? ??? ???????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\492.9 ??? ???????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\494.6 ??????? ??????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\494.9 ?????? ??????? ??????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\495.8 ??????? ??????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\496 ?????? ??????? ??????
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\496.6 ?????? ??? (2)
D:\a\07 ?????? - ??? ???? ??-????\04 ???????\??? ???\497 ???? ??? ???????

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: output end-level empty subfolders

#14 Post by abc0502 » 11 Dec 2012 07:03

it work for me here, does the notepad is supporting the language that your folders is named with?

Follow these steps:
1> Control panel
2> Regional and language options
3> select 3rd tab "advanced"
4> choose your language in "language for non-unicode programs" section and then reboot.

also, make sure that in the 2nd tab "languages" in supplemental language support section, the 1st choice is choosed "install files for complex script and right-to-left language..." if your language is wrote from right-to left

That might be the reason why the notepad doesn't display the characters in correct format.

Post Reply