This PowerShell script is part of a group of CSV Tools I have written. The script is a simple one that simply removes the last line of an inputted CSV file. It can obtain the CSV file either by being directly passed the name of a CSV file, by being given a text file list or finally by searching a directory for all CSV files.

I wrote this particular script in conjunction with my Mass NTFS Compression Tool as I was using a large Treesize report of over 3 million lines. I didn’t particularly fancy throwing 3 million lines at a script in one hit. I used a piece of software called GSplit to split the CSV file into multiple files, however due to the way the software works, it adds an extra line at the end of the file to merge the split copies back into the original at a later date. I had no need for this functionality and, while it wasn’t a major problem, I didn’t want my other scripts to throw errors because they didn’t understand this last line.

Usage: .\CSV-RemoveLastLine.ps1 [-CSV path\to.csv] [-List path\to\csvlist.txt] [-Dir path\to\directory]

download-icon.273921f460a0c6119fe317a1393d1ce1 Download CSV Tool: Remove Last Line v1.1