REMOVE AND REPLACE IN STRING // Batch Scripting Part -12- REMOVE AND REPLACE IN STRING
Channel: Techno Puffin
Date: 2020-06-06

Go and check out course on Udemy for PowerShell:
https://www.udemy.com/course/powershell-for-beginners-master-the-concepts-step-by-step

Title: BATCH SCRIPTING// REMOVE AND REPLACE IN STRING // Batch Scripting Part -12- REMOVE AND REPLACE IN STRING 
In this lesson, you will be learning about REMOVE AND REPLACE IN STRING for Batch Script. 

REMOVE: The string substitution feature can also be used to remove a substring from another string.


Example
@echo off 
set str = Batch file created here. 
echo %str% 

set str = %str:file = % 
echo %str%
The key thing to note about the above program is, the ‘is’ word is being removed from the string using the :’stringtoberemoved’ = command.

Output
The above command produces the following output.
Batch file created here.  
Batch  created here. 

REMOVE BOTH ENDS : This is used to remove the first and the last character of a string

Example
@echo off 
set str = Batch file created here. 
echo %str% 
set str = %str:~1,-1% 
echo %str%
The key thing to note about the above program is, the ~1,-1 is used to remove the first and last character of a string.

Output
The above command produces the following output.
Batch file created here.
atch file created here
REMOVE ALL SPACES: This is used to remove all spaces in a string via substitution.

Example
@echo off 
set str = Batch file created here.
echo %str% 

set str=%str: =% 
echo %str%
The key thing to note about the above program is, the : = operator is used to remove all spaces from a string.

Output
The above command produces the following output.
Batch file created here.
Batchfilecreatedhere.

REPLACE STRING: To replace a substring with another string use the string substitution feature.

Example
@echo off 
set str=Batch file created here.
echo %str% 

set str=%str:file=files% 
echo %str%
The key thing to note about the above program is, the example replaces the word ‘needs’ with the string ‘has’ via the statement %str:needs = has%

Output
The above command produces the following output.
Batch file created here.
Batch files created here.
=======================================================
If you have any questions, please post them. Don't forget to comment, like, rate and subscribe
=====================================================
Batch file programming tutorial // CREATE BATCH FILE // Batch Scripting Part-1 -- https://youtu.be/IcWYgOtohPg

Batch file programming tutorial // Batch Scripting Part-2 - Basic Batch Commands -- https://www.youtube.com/watch?v=cJ38oF3seus

Batch file programming tutorial // COPY COMMAND // Batch Scripting Part-3 - COPY Batch Command -- https://www.youtube.com/watch?v=d_0Nyxj2Xtg

Batch file programming tutorial // DEL COMMAND // Batch Scripting Part-4 - DEL Batch Command -- https://www.youtube.com/watch?v=iWbEg5SppMk


Batch file programming tutorial // MOVE COMMAND // Batch Scripting Part-5 - MOVE Batch Command -- https://www.youtube.com/watch?v=mUJxJUM6O6o

Batch file programming tutorial // ATTRIB COMMAND // Batch Scripting Part-6 - ATTRIB Batch Command -- https://www.youtube.com/watch?v=kUI9HiYTpRk

Batch file programming tutorial // FIND COMMAND // Batch Scripting Part-7 - FIND Batch Command -- https://www.youtube.com/watch?v=FnoQt-1s4u0

Batch file programming tutorial // VARIABLES IN BATCH SCRIPT // Batch Scripting Part- 8 - VARIABLES -- https://www.youtube.com/watch?v=Q0sJHcqF5Gg

DO NOT CLICK // LOCAL AND GLOBAL VARIABLES IN BATCH SCRIPT // Part- 9 - LOCAL AND GLOBAL VARIABLES -- https://youtu.be/fAVTakZ5Hhw


BATCH SCRIPTING // STRINGS IN BATCH SCRIPT // Batch Scripting Part- 10 - STRINGS -- https://www.youtube.com/watch?v=AFf1LlFdnyY


BATCH SCRIPTING// LEFT, MID AND RIGHT STRINGS// Batch Scripting Part- 11- LEFT, MID AND RIGHT STRING -- https://www.youtube.com/watch?v=Ci4WT-Le3J4


======================================================
Check out other videos


WEAPONS THAT CAN DEFEAT THANOS -- https://www.youtube.com/watch?v=nvlez


MS PAINT TRICK -- https://www.youtube.com/watch?v=4IvBC


Matrix Effect  -- https://www.youtube.com/watch?v=_EeyZYziH9A