Delete multiple files or folders input from a CSV file (Powershell)

*** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK ***
This script will delete one or more files or folders based on input of a list from a CSV file. I wrote this to work in conjunction with this script: http://www.signalwarrant.com/2013/04/20/search-file-structure-for-a-file-or-file-type-and-put-the-results-in-a-csv-file-powershell/.

Pretty simple but very effective.

 

 

3 Comments

  1. Joe Shmoe | | Reply

    Thank you for the script that you have provided. How do I export the results into an Excel spreadsheet and highlight them in green once the files have been deleted from a csv list in PowerShell?

  2. Joe Shmoe | | Reply

    How do I export the results into an Excel spreadsheet and highlight them in green once the files have been deleted from a csv list in Powershell?

    • Greg | | Reply

      Joe,

      I expect you’ve found your answer to this question, or moved on by now. But if others have the same question, here are a couple possible solutions.

      You’d have to format the text after you exported it, since CSV doesn’t support colored text as far as I know. To create the CSV from your results, you could pipe the last command to a CSV file, or use PowerShell’s Tee object to direct the output to a CSV and elsewhere: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-5.1.

      -Greg

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.