Vijay said:
I want to delete folders with command prompt, when i run command , it
should
be automatically deleted.
location of the folder my be different,
As others have said, deleting folders with wildcards is dangerous business.
If you're prepared to wear the risk, here is how you can do it:
1. Copy and paste the code below into c:\Windows\DelFolder.bat.
2. Unwrap wrapped lines.
3. Make Line 3 like so: set Active=No
4. Remove the line numbers.
5. Save the file.
6. To delete all folders starting with "abc", invoke the batch file like so:
DelFolder c:\documents and settings\Vijay\abc
Do *not* write it like so:
DelFolder c:\documents and settings\Vijay\abc*
7. If you are happy with the result, set Active=Yes in Line 3. You will
be asked for a confirmation before the folder is deleted. No folder
will be deleted just yet.
8. If you are prepared to wear the risk, set Active=Rip in Line 3. You
will *not* be asked for any confirmation. No folder will be deleted
just yet.
9. If you are happy with Steps 8 and 9, remove the words "echo" in
Lines 21 and 25. The batch file will now be fully active.
Note: You run this batch file at your own risk.
[01] @echo off
[02] rem Possible values for Active: No, Yes, Rip
[03] set Active=Rip
[04] if "%*"=="" (
[05] echo Missing folder specicfication.
[06] pause
[07] goto :eof
[08] )
[09] for %%a in ("%*") do set Folder=%%~dpa
[10] for /F "delims=" %%a in ('dir /s /b /ad "%Folder%" ^| find /i "%*"') do
call :Sub %%a
[11] goto :eof
[12]
[13] :Sub
[14] if /i %Active%==Yes goto Yes
[15] if /i %Active%==Rip goto Rip
[16] echo Folder=%*
[17] goto :eof
[18]
[19] :Yes
[20] set /p confirm=Delete "%*%? (Y/N)
[21] if /i "%confirm%"=="Y" echo rd /s /q "%*"
[22] goto :eof
[23]
[24] :Rip
[25] echo rd /s /q "%*"