Reputation: 57
I am using the following snippet to remove CRLF from a file. Is there a way to call this file to remove all CRLF from each file if I specify a directory.
@echo off
setlocal DisableDelayedExpansion
(for /F "usebackq delims=" %%a in (%1) do (
set /P "=%%a"< NUL )
)>%2
I have many directories below the root directory with multiple files in each.
Upvotes: 0
Views: 96
Reputation: 24466
Add an outer for /r "%~1" %%I in (*.mask)
loop, and change your for /F
loop to act on %%I
. In a cmd console, type help for
for more information. Here, see if this works:
@echo off
setlocal enabledelayedexpansion
rem // for each .txt file recursively in source:
for /R "%~1" %%I in (*.txt) do (
rem // get relative path + filename of %%I
set "relative=%%I" & set "relative=!relative:%~1=!"
rem // create relative directory structure in destination
for %%a in ("%~2\!relative!") do md "%%~dpa" 2>NUL
rem // for each line of src, output without line break to dest
(
for /F "usebackq delims=" %%a in ("%%~fI") do (
set /P "=%%a"< NUL
)
) >"%~2\!relative!"
)
Upvotes: 1