Home > Enterprise >  How to remove spaces in the File name of the text file?
How to remove spaces in the File name of the text file?

Time:12-28

The file is not added in the destination path if it has spaces in the file name.

For example, if the filename is textfile1.txt -> it will be added in the destination path. However, if the directory filename has space like this text file4.txt it will not be added.

Is there a way to remove the spaces of the filename? Here is the image:

Kindly check the image here

Here is my main concern:

Check this

Here is my script:

@ECHO off
TITLE (c) ASDG 
SETLOCAL EnableDelayedExpansion

SET locationPath=C:\Textfiles\
SET destinationPath=E:\Textfiles\
SET status=success
SET countMetadata=0
SET countPDF=0
SET countJPEG=0

ECHO Executing the program...
FOR /R %locationPath% %%g IN (*.txt) DO (
    CD %%~dpg
    IF EXIST *.txt* (
        FOR /F "skip=1 tokens=1* delims=|" %%a IN (%%~nxg) DO (
            SET /a countMetadata =1
            ECHO %%~dpa%%a^| %%b >>            
  • Related