Web Development

General discussion


DOS-checking empty folder

By bestbuddy83 ·
Sorry to ask. I have your email address through your ex-student. I asked them about the DOS and we finally stuck and they asked me to ask you about this. I need some advice in this script which I wished I don?t cause you any inconvenience.

I?m currently writing some simple script in DOS. My only concern is that the input part. I want the input is automatically inserted. Users don?t have to key in the data.

As an example:

(This is the script to check whether the folder is empty)

@echo off


if {%1}=={ } set _empty=Syntax : empty.cmd ?C:\Folder to check? & GOTO: message

:: check whether the folder is exist

IF NOT EXIST %1 set _empty=No Such Folder & GOTO: message

:: check whether the folder is empty

Dir %1 /b | find /v ?0471391E-c911-11D9-8BDE-F66BFD1E3F3A? >NUL && (set _empty=Not Empty) || (set _empty=Empty)


echo %_empty%

endlocal & set _empty=%_empty%

If I?m not mistaken, the %1 sign required user to enter the value. I?m stuck. What I want is that the program received the input from the set of folder in the C automatically.

Let say,

@echo off

cd C:\?Documents and Settings?\nanoar

dir C:\?Documents and Settings?\nanoar\* /a:d /b >>dir-list.txt

FOR /f %%l IN (dir-list.txt) DO set file=?%%1? & CALL : empty >>log2.txt


Dir %file% /b | find /v ?0471391E-c911-11D9-8BDE-F66BFD1E3F3A? >NUL && (set _empty=Not Empty) || (set _empty=Empty)

But, this is program is full of errors. What I want is that the :empty will check the folder which is listed in the dir-list.txt whether the folder is empty or not. Is there anything I missed?

Please help me. Thanks you very much.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums