Sunday, September 16, 2012

Create Virtual drive using Dos command

SUBST


Syntax

Associates a path with a drive letter.


SUBST [drive1: [drive2:]path]

SUBST drive1: /D

drive1: Specifies a virtual drive you want to assign a path.

[drive2:]path Specifies a physical drive and path you want to assign to a virtual drive.

/D Deletes a substituted (virtual) drive.


Type SUBST with no parameters to display a list of current virtual drives.



Examples


C:/>SUBST z: C:/porject/rms

C:/> SUBST z: /D      (Deletes the virtual drive.)

Sets the directory you are in and subdirectories thereafter into the A: drive. So if you were to type A: after doing this command you would see everything in the directory that you typed this command in.

If you were to reboot your computer this will clear the SUBST command and put your drives back to original letters (unless command placed into the autoexec.bat).



Find String in Files using Dos command

FINDSTR
Search for strings in files.



Syntax

FINDSTR [options] [/F:file] [/C:string] [/G:file]

[/D:DirList] [/A:color] [/OFF[LINE]] [string(s)] [pathname(s)]



FINDSTR [options] [/F:file] [/R] [/G:file]

[/D:DirList] [/A:color] [/OFF[LINE]] [string(s)] [pathname(s)]

Key

string Text to search for.

pathname(s) The file(s) to search.

/C:string Use string as a literal search string.

/R Use string as a regular expression.

/G:file Get search string from a file (/ stands for console).

/F:file Get a list of pathname(s) from a file (/ stands for console).

/A:color Display filenames in colour (2 hex digits)

/d:dirlist Search a comma-delimited list of directories.



options may be any combination of the following switches:

/I Case-insensitive search.

/S Search subfolders.

/P Skip any file that contains non-printable characters

/OFF[LINE] Do not skip files with the OffLine attribute set.

/L Use search string(s) literally.

/B Match pattern if at the Beginning of a line.

/E Match pattern if at the END of a line.

/X Print lines that match exactly.

/V Print only lines that do NOT contain a match. /N Print the line number before each line that matches.

/M Print only the filename if a file contains a match.

/O Print character offset before each matching line.


Example:

C:/Docs/test> findstr /I /S /P /M "Venkata Naresh" *

Explanation:

Search "Venkata Naresh" in all the files in folder "C:/Docs/test".