0

I am very new to creating bat filed. I am trying to delete the old files from the drive - pause to run the new file from the software, then remove the 1st line from my csv file and the " from the entire file.

Here is what I have written so far but cannot get the " removed.

@echo off
DEL C:\users\thutchinson\downloads\APDD*.*
start "" /wait cmd /c "echo Run the Dayforce Report!&echo(&pause"
@echo off

RENAME C:\Users\thutchinson\Downloads\APDD*.csv APDD1.txt
@echo off
more /E +1 C:\Users\thutchinson\Downloads\APDD1.txt >C:\Users\thutchinson\Downloads\APDD2.txt
set Sting

msg * Done!
exit >nul
Squashman
  • 13,649
  • 5
  • 27
  • 36
  • 1
    I don't see any code that even remotely attempts to remove quotes from the file. Hard to help you troubleshoot code when there isn't any. – Squashman Apr 23 '21 at 17:54

1 Answers1

0

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%

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • kindly advice on this https://stackoverflow.com/questions/67298541/run-several-indexes-as-a-service-using-fscrawler – Denn Apr 28 '21 at 12:11