Replace specified texts in a file using CMD

Save this .bat Files:
replaceprocess.bat
=================================

@echo off &setlocal
set /p "search=TextToReplace:"
set /p "replace=TextToReplaceWith:"
(for /f "delims=" %%i in (TextSearch.java) do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    set "line=!line:%search%=%replace%!"
    echo(!line!
    endlocal
))>C:\Users\Krishna\Desktop\CMD\TextSearch_Modified.java

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

Run above batch file as:

C:\Users\Krishna\Desktop\CMD>call replaceprocess.bat
TextToReplace:public
TextToReplaceWith:private


List all Sub Folders|| Files into Excel of a Folder

Suppose We have a folder names MyFiles that contains thousends folders and we want to list down all the folder.So it is a bit time taking prcess to list all the folders into excel.
But there is 2 Sec which list all in seconds.
Use this Command
C:\Users\Krishna\Downloads\src\aura>dir /a /b /o >C:\Users\Krishna\Desktop\CMD\f.xls
OR
C:\Users\Krishna\Desktop\CMD>dir /a /b /o *.txt
OR
C:\Users\Krishna\Desktop\CMD>dir /a /b /o *.*

where:


/ADisplays files with specified attributes.
attributes
D DirectoriesR Read-only files
H Hidden filesA Files ready for archiving
S System filesI Not content indexed files
L Reparse Points- Prefix meaning not
  
/BUses bare format (no heading information or summary).
/CDisplay the thousand separator in file sizes, which is the default setting. Use /-C to disable display of separator.
/DSame as wide but files are list sorted by column.
/LUses lowercase.
/NNew long list format where file names are on the far right.
/OList by files in sorted order.
sortorderN 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
/PPauses after each screenful of information.
/QDisplay the owner of the file.
/RDisplay alternate data streams of the file.
/SDisplays files in specified directory and all subdirectories.
/TControl what time field displayed or used for sorting
timefieldC Creation
A Last Access
W Last Written
/WUses wide list format.
/XDisplays 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.

DOS Programming

@echo off
rem demo all arithmetic operator

rem set /p is used for prompt reading on variable
set /p val1="Enter first value :"
set /p val2="Enter second value :"

echo ********* arithmetic operator demo ************
rem set /a is used for arithmetic calculation
set /a res=%val1%+%val2%
echo Sum of %val1% and %val2% is %res%

set /a res=%val1%-%val2%
echo Subtraction of %val1% and %val2% is %res%

set /a res=%val1%*%val2%
echo Multiplication of %val1% and %val2% is %res%

set /a res=%val1%/%val2%
echo Division of %val1% and %val2% is %res%

set /a res=%val1%%%val2%
echo Modulo division of %val1% and %val2% is %res%

echo ********* relational operator demo @@ geq,gtr,equ,lss,leq @@************
if %val1% gtr %val2% (
echo %val1% is greater than %val2%
) else (
if %val1% lss 10 (
echo %val1% is even less than 10
) else (
echo %val1% is less than %val2%
)
)

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

@echo off
rem check for leap year using if else
set /p yval= "Enter year value :"
set /a res=%yval%%%4
if %res%==0 (
echo "%yval% is a leap year"
) else (
echo "%yval% is not a leap year"
)

rem check if file is available or not
set filename=savecustomer1.sql
if exist %filename% (
echo File exist
) else (
echo File does not exist
)

rem check exit status of last running command
DEL test.txt
if %ERRORLEVEL%==1 (
echo last operation was successful
) else (
echo problem in last operation
)

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

@echo off
echo *****Simple numeric for loop*****
FOR /L %%G IN (2,1,5) DO echo %%G

echo *****for loop working on collection*****
FOR %%G IN (Sun Mon Tue Wed Thur Fri Sat) DO echo %%G

echo *****for loop /R reading files of current directory recursively *****
For /R %%G in (*.*) do Echo "%%G"

echo ***** looping file contents @@@ Reading comma separated file @@@@******

FOR /F "tokens=1,2,3 delims=," %%G IN (persondata.txt) DO @echo %%G %%H %%I

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


Counters