VideoHelp Forum




+ Reply to Thread
Results 1 to 4 of 4
  1. Hi

    I'm a ***

    I'm inside a batch

    and I need to delete a file only if it exist, using powershell. Is there a way?

    something like

    Code:
    if exist file.txt del file.txt

    thanks
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    If it doesn't exist, there won't be anything that needs deleting, so even if it errors, no big deal, as long as you account for it in the flow.

    Btw, hint: sometimes the flow works better if it is set up more in the manner of "if not exist...".

    You'll have to try those on your own, though. You may purport to be a cat but I am a busy human, so don't have time to further help.

    Scott
    Last edited by Cornucopia; 21st Mar 2022 at 17:57.
    Quote Quote  
  3. Do you ever even try? I did a simple search for "powershell delete file if it exists". The first result was:

    https://buildvirtual.net/powershell-how-to-delete-a-file-if-it-exists/
    Quote Quote  
  4. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    Just do a usb linux boot and delete the file that way.
    I think,therefore i am a hamster.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!