1.

Solve : How to check if a directory is empty or not?

Answer» HI there,

I would like to copy files from one directory to another directory. If the source directory is empty, I would like to print a warning MESSAGE and skip the xcopy command. How to do it? Thank you.

J.If you test directory size in batch, it will always come up empty (restricted to files). XCOPY has the /s /e /t switches that may be ABLE to do what you need (type XCOPY /? at a command prompt for details) ALTHOUGH putting out a message could be problematic.

WinScript is always an option as folders have a SIZE property you can test.

Check out The Windows SCRIPT Center and it's links for more info.

Hope this helps. Hello,

Just made a .BAT file that answers your problem neatly:

@ECHO OFF

IF NOT EXIST %1 GOTO Error

XCOPY %1 %2
GOTO End

:Error
ECHO Source does not exist.
GOTO End

:End


Call it whatever you want; I call it ZXCOPY.BAT
Good luck!


Discussion

No Comment Found