1

I have multiple csv files in a folder.

I want to delete the first row of each csv in the folder using windows command line.

I am not familiar with windows command line so I will need information regarding how to call the folder within the console.

I do not want to make new files with the "subtracted" row, I just want to replace the original file or overwrite it.

2
  • 1
    If possible, install git bash and run linux commands (sed -i '' 1d file.csv) Commented Oct 20, 2022 at 1:12
  • Thank you, that seems like a reasonable solution, but I cannot install git bash on this machine without IT approval. Do you know how to do it in windows command line? Commented Oct 20, 2022 at 1:15

1 Answer 1

3

Use Powershell

Get-ChildItem "path\to\your\directory" -Filter *.csv | 
Foreach-Object {
    $import = Get-Content $_.FullName
    $import | Select-Object -Skip 1 | Set-Content $_.FullName
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, this seems to make sense. Can you please provide guidance to accessing all of the csvs in a folder and executing this without creating a new file? I understand that path\to\file.csv is representing the location of the folder, but when I use C:\Users\Downloads for example I get an error of unauthorized access. Does the file.csv mean look at all the csv files in the folder? Does the second like with file2.csv create a new file? I do not want it to make a new file.
Improvised the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.