Computing.Net > Forums > Programming > Batch Script Help Needed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Script Help Needed

Reply to Message Icon

Name: kil
Date: June 27, 2006 at 10:07:58 Pacific
OS: Windows XP Pro
CPU/Ram: 3.2
Product: Dell
Comment:

I need help with a batch script that will do the following:

Check to see if any folders or files exist in C:\Temp and if it does delete all folder in C:\Archive. If no folders or files exist in C:\Temp leave C:\Archive alone.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Shr0Om
Date: June 28, 2006 at 05:06:01 Pacific
Reply:

Not tested, but this should work

@echo off
c:
cd\
cd Temp
dir |find "0 File(s)"
if errorlevel 1 (exit) else goto DelArchive

:DelArchive
cd\
cd Archive
del *.*


0

Response Number 2
Name: CWoodward
Date: June 29, 2006 at 02:22:39 Pacific
Reply:

Shr00m, the above will only check for and delete files, not folders. Try this:

~~~~~chkfile.bat~~~~~

@ECHO OFF

DIR /B /S C:\Temp > FileList.txt

FOR /F %%A IN ("FileList.txt") DO IF %%~zA
EQU 0 GOTO :EOF

FOR /F "Tokens=1 DELIMS=," %%V IN ('DIR /AD /B C:\Archive') DO RD %%V

DEL C:\Archive\*.*

:EOF


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Script Help Needed

Batch Scripting Help www.computing.net/answers/programming/batch-scripting-help/14192.html

Batch Script Help www.computing.net/answers/programming/batch-script-help/16444.html

Batch Script Help www.computing.net/answers/programming/batch-script-help/15158.html