MsDos - delete directories and subdirectories

Discussion in 'Scripting' started by Mr Been, Feb 20, 2018.

  1. Mr Been

    Mr Been MDL Member

    Feb 24, 2008
    225
    59
    10
    I'm using this command :

    cd C:\Users\Administrator\AppData\Local\Temp
    rd . /Q /S

    to delete the content of this directory and its subdirectories. So far so good! No problem.

    But I don't know what this . (rd .) is good for? No documentation nowhere!!

    Thank you for your help
     
  2. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    16,738
    20,970
    340
  3. LiteOS

    LiteOS MDL Expert

    Mar 7, 2014
    1,509
    641
    60
    . is the current directory
     
  4. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    3,641
    3,939
    120
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    15,315
    21,173
    340
    OP clearly confuses names here, the example is batch code :cool2:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Sajjo

    Sajjo MDL Senior Member

    Feb 6, 2018
    492
    572
    10

    RMDIR "foldername" /S /Q

    no exclamation mark

    Delete file/folder -> switches are: /S silent, /Q quiet

    /S -> Remove a directory tree. :)
     
  7. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,544
    662
    60
    And cd is Change Dir ;)
     
  8. Palladin

    Palladin MDL Senior Member

    Feb 1, 2014
    333
    139
    10
    Some of this might be simple stuff to some.
    But might be of interest to somebody curious about some more obsure Dos commands.

    ==========================================================
    Using the "." and ".." Current and Parent Directory listing shortcuts
    ==========================================================

    ==========================================================
    Type this from an elevated command prompt

    C:\>cd \windows\system32 <---------------
    ==========================================================

    ==========================================================
    Type this from the System32 directory prompt:
    The /p switch pauses the display at a single screen.

    C:\Windows\System32>dir /p <---------------

    You should see this listing:

    Volume in drive C is Seagate
    Volume Serial Number is 0AC2-4B69

    Directory of C:\Windows\System32

    02/24/2018 04:09 AM <DIR> . <--------------- the single dot represents the current directory
    02/24/2018 04:09 AM <DIR> .. <--------------- the double dot represents the parent directory
    04/11/2011 11:38 PM <DIR> 0409
    11/20/2010 07:30 PM <DIR> AdvancedInstallers
    12/24/2015 05:40 AM <DIR> appmgmt
    07/13/2009 07:20 PM <DIR> ar-SA
    07/13/2009 07:20 PM <DIR> bg-BG
    12/22/2015 08:29 PM <DIR> Boot
    12/22/2015 08:21 PM <DIR> catroot
    02/17/2018 06:12 PM <DIR> catroot2
    12/22/2015 08:29 PM <DIR> CodeIntegrity

    At the "press any key to continue" type Ctrl-C to return to the Dos prompt
    ==========================================================

    ==========================================================
    To get the listing of the current directory of the system32 directory
    Type this at the System32 prompt:

    C:\Windows\System32>dir . /p <--------------- use 1 dot/period

    Volume in drive C is Seagate
    Volume Serial Number is 0AC2-4B69

    Directory of C:\Windows\System32

    02/24/2018 04:09 AM <DIR> .
    02/24/2018 04:09 AM <DIR> ..
    04/11/2011 11:38 PM <DIR> 0409
    11/20/2010 07:30 PM <DIR> AdvancedInstallers
    12/24/2015 05:40 AM <DIR> appmgmt
    07/13/2009 07:20 PM <DIR> ar-SA
    07/13/2009 07:20 PM <DIR> bg-BG
    12/22/2015 08:29 PM <DIR> Boot
    12/22/2015 08:21 PM <DIR> catroot
    02/17/2018 06:12 PM <DIR> catroot2
    12/22/2015 08:29 PM <DIR> CodeIntegrity
    04/11/2011 11:38 PM <DIR> com
    02/10/2018 08:06 AM <DIR> config

    At the "press any key to continue" type Ctrl-C to return to the Dos prompt
    ==========================================================

    ==========================================================
    To get the listing of the parent directory of the system32 directory which is C:\windows
    Type this at the System32 prompt:

    C:\Windows\System32>dir .. /p <--------------- use 2 dots/periods

    Volume in drive C is Seagate
    Volume Serial Number is 0AC2-4B69

    Directory of C:\Windows

    02/11/2018 03:59 AM <DIR> .
    02/11/2018 03:59 AM <DIR> ..
    07/13/2009 07:20 PM <DIR> AppCompat
    01/31/2016 05:20 AM <DIR> AppPatch
    07/13/2009 09:32 PM <DIR> Boot
    07/13/2009 09:32 PM <DIR> Branding
    12/22/2015 05:20 PM <DIR> CSC
    07/13/2009 09:32 PM <DIR> Cursors
    11/27/2016 08:47 AM <DIR> debug
    07/13/2009 09:32 PM <DIR> diagnostics
    07/13/2009 09:37 PM <DIR> DigitalLocker
    07/13/2009 09:32 PM <DIR> Downloaded Program Files

    At the "press any key to continue" type Ctrl-C to return to the Dos prompt
    ==========================================================

    ==========================================================

    You can also use wildcards with the "." but not the ".."
    For example, this will give you a listing of all of the directories in the System32 directory
    Oddly enough the ".." doesn't work with wildcards. Go figure.

    C:\Windows\System32>dir *. /p <---------------
    Volume in drive C is Seagate
    Volume Serial Number is 0AC2-4B69

    Directory of C:\Windows\System32

    02/24/2018 04:09 AM <DIR> .
    02/24/2018 04:09 AM <DIR> ..
    04/11/2011 11:38 PM <DIR> 0409
    11/20/2010 07:30 PM <DIR> AdvancedInstallers
    12/24/2015 05:40 AM <DIR> appmgmt
    07/13/2009 07:20 PM <DIR> ar-SA
    07/13/2009 07:20 PM <DIR> bg-BG
    12/22/2015 08:29 PM <DIR> Boot
    12/22/2015 08:21 PM <DIR> catroot
    02/17/2018 06:12 PM <DIR> catroot2
    12/22/2015 08:29 PM <DIR> CodeIntegrity

    At the "press any key to continue" type Ctrl-C to return to the Dos prompt
    ==========================================================

    ==========================================================
    You can use the .(dot) and ..(dot dot) at the command prompt for almost any dos command,
    except rd (remove diretory) if you are in that directory.
    And you cannot delete the parent directory (..) either.

    For example:

    C:\Temp\foo>rd . <---------------
    The process cannot access the file because it is being used by another process.


    C:\Temp\foo>rd .. <---------------
    The directory is not empty.
     
  9. Mr Been

    Mr Been MDL Member

    Feb 24, 2008
    225
    59
    10
    Thank you PALLADIN

    your post was the most helpful. All I need to know!
    but nevertheless, thanks to all others too.