I figured you were trying to replace the file content with the more
command, so figured I would assist you here.
Disclosure, this script result will completely depend on the contents of your csv
file. If it has characters such as !
and <
>
. This will not work correctly.
So before I begin, let me also explain that I am assuming (based on your sample rename command) that you are trying to do this for each .csv
file in a folder, if not, review the code, because this is going to replace the content as you requested.
@echo off
setlocal enabledelayedexpansion & mkdir "%temp%\bckcsv"
for %%i in (*.csv) do (
copy "%%~i" "%temp%\bckcsv"
set "file=%%~i"
for /f "skip=1tokens=*" %%f in ('type "!file!" ^| find /v /n "" ^& break ^> "!file!"') do (
set "line=%%f"
set "line=!line:*]=!"
set "line=!line:"=!
echo(!line! >>"!file!"
)
)
Again, do not run this in your directory where you are planning to run it in. Copy some of the files to a test directory, run the batch on that directory and ensure the results are as you expected before you run this on your actual files. If however you have failed to read this before attempting and you managed to break your csv
files, not to worry too much, this code had them backed up for you in %temp%