General discussion

Locked

Batch file needed

By roman_empire ·
I need a batch file that will take two arguments 'rootdirectory' and 'junkdirectoryname'. It should search 'rootdirectory' and all its subdirectories and delete all directories named 'junkdirectoryname' on all levels. It should also error check inthe begining that both arguments were provided and 'rootdirectory' exists.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Batch file needed

by tchieng In reply to Batch file needed

Your program there can not be done easily with a batch file. Your best bet is to do it in a programming language like C or Pascal that can do recursive calls.

Look on the Internet. It probably already exists somewhere - just need to find it. Can't find one? I might be able to write you one if I have some free time.

Collapse -

Batch file needed

by roman_empire In reply to Batch file needed

Look at the next answer

Collapse -

Batch file needed

by andreas.vavra In reply to Batch file needed

Download and try KillJunk.cmd at http://come.to/vaviland (at your own risk!).

Regards,
Andreas Vavra

Collapse -

Batch file needed

by roman_empire In reply to Batch file needed

@echo off
REM ########
REM ## KillJunk.cmd by Andreas Vavra (Andreas.Vavra@brz.gv.at) (C) 2000
REM ## aka Vavi (andi@compass.co.at)
REM ##
REM ## This scripts removes all directories named %2 in %1 including all of their
REM ## subdirectories.
REM ##
REM ## USE AT YOUR OWN RISK!
REM ##
REM ########

if (%1)==() goto USAGE
if (%2)==() goto USAGE

if not exist %1 goto NOROOT

cd /D %1
for /D /R %%i in (*.*) do if (%%~ni)==(%2) rd %%i /S /Q
goto ENDE

:NOROOT
echo root-dir %1 does not exist
goto ENDE

:NOJUNK
echo junk-dir %2 does not exist
goto ENDE

:USAGE
echo USAGE killjunk.cmd "root-dir" "junk-dir-name"
goto ENDE

:ENDE

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums