How to use dir command

satya - Tuesday, November 27, 2007 10:03:17 AM

basic syntax


Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

  [drive:][path][filename]
              Specifies drive, directory, and/or files to list.

  /A          Displays files with specified attributes.
  attributes   D  Directories                R  Read-only files
               H  Hidden files               A  Files ready for archiving
               S  System files               -  Prefix meaning not
  /B          Uses bare format (no heading information or summary).
  /C          Display the thousand separator in file sizes.  This is the
              default.  Use /-C to disable display of separator.
  /D          Same as wide but files are list sorted by column.
  /L          Uses lowercase.
  /N          New long list format where filenames are on the far right.
  /O          List by files in sorted order.
  sortorder    N  By name (alphabetic)       S  By size (smallest first)
               E  By extension (alphabetic)  D  By date/time (oldest first)
               G  Group directories first    -  Prefix to reverse order
  /P          Pauses after each screenful of information.
  /Q          Display the owner of the file.
  /S          Displays files in specified directory and all subdirectories.
  /T          Controls which time field displayed or used for sorting
  timefield   C  Creation
              A  Last Access
              W  Last Written
  /W          Uses wide list format.
  /X          This displays the short names generated for non-8dot3 file
              names.  The format is that of /N with the short name inserted
              before the long name. If no short name is present, blanks are
              displayed in its place.
  /4          Displays four-digit years

Switches may be preset in the DIRCMD environment variable.  Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.

satya - Tuesday, November 27, 2007 10:06:11 AM

how to find files older newer than a certain date

Search for: how to find files older newer than a certain date

satya - Tuesday, November 27, 2007 10:08:57 AM

xcopy syntax


Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

satya - Tuesday, November 27, 2007 10:12:10 AM

use the /L option to display only

use the /L option to display only

satya - Tuesday, November 27, 2007 10:15:09 AM

example


xcopy .\*.java c:\temp /s /L /D:11-22-2007

Show java files that are more recent than Nov 22nd, 2007 in the current directory and sub directores.

/s indicates to span sub directories

/L is to display only

you need to have a target directoty. use this with caution. For some reason if you omit the /L you will end up copying.

satya - Friday, April 18, 2008 9:07:16 AM

How to copy more recent files from one dir to another dir


xcopy src dest /D /s /e

satya - Friday, April 18, 2008 9:07:48 AM

/D stands for more recent

/D stands for more recent

/s all subdirectories

/e including empty ones

satya - 7/17/2015, 10:59:34 AM

can i mount a windows share as a drive letter?

can i mount a windows share as a drive letter?

Search for: can i mount a windows share as a drive letter?

satya - 7/17/2015, 11:07:49 AM

You can use mklink but you need permission


MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

satya - 7/17/2015, 11:45:15 AM

What are volume mount points

What are volume mount points

satya - 8/8/2016, 4:02:25 PM

Here is the micrsoft link for other xcopy options

Here is the micrsoft link for other xcopy options

satya - 8/8/2016, 4:03:12 PM

Some of interest


/c : Ignores errors.
/y : Suppresses prompting to confirm that you want to overwrite an existing destination file.

satya - 2/4/2024, 6:41:08 PM

Copy the new files from source to target including hidden files like .git


xcopy /src-dir /target-dir /s /e /H /D

/H - Hidden, you need this for git
/D - More recent
/s - all sub dirs
/e - empty dirs

satya - 2/4/2024, 6:45:06 PM

Micorsoft docs on xcopy options in windows

Micorsoft docs on xcopy options in windows

Search for: Micorsoft docs on xcopy options in windows

satya - 2/4/2024, 6:46:10 PM

Why the search

  1. 1. Links to the docs change all the time
  2. 2. So just use the search instead
  3. 3. below is a link as of 2024

satya - 2/4/2024, 6:46:43 PM

MS xcopy is documented under windows server admin here

MS xcopy is documented under windows server admin here