Jump to content

techbrainless

Member
  • Posts

    5
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Yemen

Posts posted by techbrainless

  1. Thanks to who replied,

    Especial Thanks to jaclaz (many more thanks) , allen2 && I apologize to all for my rough reply,

    @echo off

    SETLOCAL ENABLEEXTENSIONS

    for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do ECHO del /q "%%A"

    for /f "Tokens=*" %%A in ('dir /B /S /A:D') do ECHO rd /s /q "%%A"

    It works like a charm ........... Again my thanks to jaclaz,allen2

    Not only he doesn't understand, he also starts shouting! :w00t::ph34r:

    OBVIOUSLY, since it is potentially VERY dangerous code, I added a basic safeguard to avoid that some demented users would copy and paste it "as is" in the WRONG place (and delete everything in the subtree by mistake.

    The idea was to NOT allow someone that cannot even read two lines of batch to potentially make damages.

    Since OP asked help in writing a batch file and posted a non-working code that not only doesn't work but is is also evidently NOT following very basic batch or command line syntax, I assumed he was not at all familiar and thought that a safeguard would have been needed.

    I totally agree with you , I dont know even low level basics of batch script and i did not put any effort to learn it.....It was my mistake

    I am sure that your above reply encouraged me alot to start learning batch script and also to spend time trying to understanding the things and trying to solve the problems before post a question.

  2. Thanks jaclaz for your reply ,

    @echo off

    SETLOCAL ENABLEEXTENSIONS

    for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do ECHO del /q "%%A"

    for /f "Tokens=*" %%A in ('dir /B /S /A:D') do ECHO rd /s /q "%%A"

    1. I have copied the above code into empty batch file, saved it , double clicked on it ( batch file) , but nothing happened ( nothing got deleted)

    2. I tried to copy , paste the above code into DOS prompt but it displayed error and got hang as the following

    D:\test>@echo off
    SETLOCAL ENABLEEXTENSIONS
    for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do ECHO del /q "%%
    A"
    %%A was unexpected at this time.
    for /f "Tokens=*" %%A in ('dir /B /S /A:D') do ECHO rd /s /q "%%A"
    %%A was unexpected at this time.

  3. Thanks for your reply

    You are going to have to explain where the batch file is going to be located, how it is going to be invoked and probably what you mean by current working directory!

    Let us assume that we have placed the .batch file at the location "D:\test\mybatch.bat"

    once you have browsed to the directory "test" , double clicking on the batch file "mybatch.bat" , it should delete all the contents of the directory "test" ("D:\test")

    off course the batch file should delete all the contents of "test" directory except itself "mybatch.bat"

  4. Hi All ,

    I want to create a batch file , which do the following

    1. first get the current working directory

    2. delete all the contents(files, directories ,sub directories) of the current working directory

    by the way i have tested the following code but it does not work for me

    D:\test>for / d% i in (s *.*) DO del% i / Q / S
    / was unexpected at this time.

    D:\test>for / d% i in (s *.*) DO rd% i
    / was unexpected at this time.

    D:\test>

    Could you plz help me ?

    BTW I am using XP , and I want to apply the batch to XP , Vista , Win 7

×
×
  • Create New...