Showing posts with label Dos. Show all posts
Showing posts with label Dos. Show all posts

Friday, July 5, 2019

Get all installed programs list using command prompt

Use Windows Management Instrumentation Command line tool (WMIC) in the Command Prompt window, that will help you to get List of Programs.

Step 1:
Open Command Prompt, Win + R (type "cmd")

Step 2:
type “wmic” and press Enter at command prompt.

You will get prompt as wmic:root\cli> 

Type following command that will create text file with the details.
wmic:root\cli> /output:C:\ListOfInstalledPrograms.txt product get name,version

Note: you can use any number of column at the end of command

once the command is executed, it will be back to command prompt, type "exit" to quite from wmic prompt.


Thursday, July 4, 2019

Merge multiple .csv files available in same folder using CMD command

This is a trick which can save you a lot of time when working with a dataset spread across multiple CSV files. Using a simple CMD command it is possible to combine all the CSV’s into a single .CSV file.

Command:
c:\> copy *.csv combine.csv

that's it. Hope this will save your time.

Tuesday, June 25, 2019

File Row Count using Batch file in a directory

Copy and Paste following code in a batch file, that will count rows in file (csv, txt, etc.,) available in the directory.

@ECHO OFF
setlocal enabledelayedexpansion
for %%f in (*.csv) do (
  set /p val=<%%f
  find /v /c "" %%f
)

Row count with DOS "Find Command"

Windows find command :

Using ‘Find’ command,  we can search for specific text in a set of files. Find below the syntax of this command with examples. Note that windows find command is different from the Linux find command in functionality. Linux find command is used to search for files that match the given criteria. But the windows find command is useful to search files for the lines that match the given string. The windows command that matches partially with Linux find command’s functionality is dir command.

Syntax and Examples

Find the lines of a file that have the specified string
find "string" filename
Ex:

C:\>find "Windows" C:\boot.ini
---------- C:\BOOT.INI
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect


To print line numbers along with the lines
find /N "string" filename
Ex:

C:\>find /N "Windows" C:\boot.ini
---------- C:\BOOT.INI
[5]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect



To ignore case in searching for the string, we can add /I switch.
find /I /N "string" filename
In the below example, we don’t find any matching lines when we search for ‘windows’. In the next command, I have added /I and it shows the matching line ignoring the case differences.

C:\>find /N "windows" C:\boot.ini

---------- C:\BOOT.INI

C:\>find /N /I "windows" C:\boot.ini

---------- C:\BOOT.INI
[3]default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[5]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect


To find the lines that are not matching with the given string:
We can use /V switch for this case. Please find the command syntax below.

find /V  "string" filename
Ex:

C:\>find /N "windows" C:\boot.ini
---------- C:\BOOT.INI

C:\>find /N /I "windows" C:\boot.ini

---------- C:\BOOT.INI
[3]default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[5]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect




Reference Site


Wednesday, May 21, 2014

Creating a file name as a Date stamp in a batch File


Source Code line
Dir>C:\myFile_%date:/=%.log

Output File Name
myFile_05212014.log