1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do you write a prog/batch/file to delete files?

Discussion in 'White Hat SEO' started by derpywizard, Jan 21, 2011.

  1. derpywizard

    derpywizard Regular Member

    Joined:
    Sep 6, 2010
    Messages:
    288
    Likes Received:
    54
    How can I create a program or app or batch file or something that will allow me to delete a certain folder except for some content when I click it?

    ie.

    I write program.exe and when I click it and it runs it deletes

    C://Data/Folder1

    -except it leaves everything but 1 file ie. C//Data/leftoverfile.dll

    Basically I just want it to delete everything in the folder except for 1 or 2 files and leave them in the root folder.

    Thanks guys!
     
  2. darnoldi

    darnoldi Registered Member

    Joined:
    Jan 6, 2011
    Messages:
    52
    Likes Received:
    20
    I'm Assumng you are on windows?

    If so this code should do it.

    Code:
    mkdir c:\temp
    copy c:\myfolder\file1.dll c:\temp
    copy c:\myfolder\file2.dll c:\temp
    del /S /Q c:\myfolder\*.*
    copy c:\temp\file1.dll c:\myfolder
    copy c:\temp\file1.dll c:\myfolder
    rmdir /S /Q c:\temp
    create a yourname.bat file and put this code into it.
    obviously edit filenames and folders as appropriate.


    HTH

    Dave
     
    Last edited: Jan 22, 2011