Sunday, May 31, 2026

Batch Program - Move files of specific type to Target folder using BAT file

Using the following Batch programming code, you can Move files of specific type to a target folder. 
  • SET command is used to declare variable and initialize it.
  • If Target folder is missing then MD command creates the target folder.
  • CD command is is used to change directory from D Drive to G:\PowerPoint Y25 folder.
  • The FOR loop loops all MP4 files in the source folder and 
  • DO command uses a number of actions inside its parentheses ().
  • %%i is loop variable which scope is inside the loop.
  • %%nxi stands for filename with extension for each i i.e. mp4 type file.
  • MOVE command is used to move from source to target folder.
  • REM stands for comments in batch code.
  • ECHO command prints the text on console.
@ECHO OFF

SET "SourceDir=G:\PowerPoint Y25"
SET "DestinationDir=G:\Lesson4"
SET "SearchTerm=React"

REM --- 1. Ensure the destination directory exists ---
IF NOT EXIST "%DestinationDir%\" MD "%DestinationDir%"

REM --- 2. Change to the source directory for the search ---
CD /D "%SourceDir%"

REM --- 3. Loop through all PDF files and check the filename ---
FOR %%i IN (*.mp4) DO (
    ECHO Checking: "%%~nxi"
    
    REM Note: Removed the /I switch for case-sensitivity
    ECHO "%%~nxi" | FIND "%SearchTerm%" >NUL
    
    REM This checks: IF the error level is NOT greater than or equal to 1
    REM i.e., IF error level is exactly 0 (Match Found)
    IF NOT ERRORLEVEL 1 (
        ECHO **MATCH FOUND! Moving file: "%%~nxi"**
        
        REM Move the file to the destination folder
        MOVE "%%i" "%DestinationDir%"
    ) ELSE (
        ECHO No match found.
    )
)

PAUSE

Saturday, May 30, 2026

VBA Word - Delete All Horizontal Lines from a Word document

Use the following VBA code to delete All Horizontal Lines from a Word document:
Sub DeleteAllHorizontalLines()

    Dim oPara As Paragraph
    Dim oShape As InlineShape
    
    ' --- PART 1: Remove Horizontal Lines that are Paragraph Borders ---
    ' Loop through every paragraph in the main document story
    For Each oPara In ActiveDocument.StoryRanges(wdMainTextStory).Paragraphs
        ' Set the bottom border style to "None"
        oPara.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    Next oPara
    
    ' --- PART 2: Delete Horizontal Line Shapes (Drawings/Graphics) ---
    ' Loop through all Inline Shapes in the main document story
    ' We loop backwards in case multiple shapes are deleted in a row
    Dim i As Long
    For i = ActiveDocument.InlineShapes.Count To 1 Step -1
        Set oShape = ActiveDocument.InlineShapes(i)
        
        ' Check if the shape is a dedicated horizontal line object
        If oShape.Type = wdInlineShapeHorizontalLine Then
            oShape.Delete
        End If
    Next i

    MsgBox "All common horizontal lines have been removed!", vbInformation

End Sub

Hot Topics