Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Automatically Delete BAK Files

  1. #1
    100 Club jsr13's Avatar
    Join Date
    2004-09
    Location
    Virginia - USA
    Posts
    130

    Default Automatically Delete BAK Files

    I'm only vaguely familiar with batch files, but I remember hearing some time ago that you can create a batch file that can be run each night to delete all of the BAK files on the server each night before our backup routine is run to cut down on the size of the backup. It would need to be able to delete files in the subfolders on our Projects server.
    I feel like this should be a very simple thing, but not having the background with batch files makes the websites I've found dealing with them a bit confusing.


    Can anyone help??

    Thanks in advance!!!
    Jeff Rayhorn

    Sinclair Pratt Cameron, P.C.
    Consulting Structural Engineers
    Virginia Beach
    Virginia, USA

  2. #2
    100 Club RobertAitken's Avatar
    Join Date
    2000-10
    Location
    Sunny Scotland
    Posts
    148

    Default Re: Automatically Delete BAK Files

    Quote Originally Posted by jsr13
    I'm only vaguely familiar with batch files, but I remember hearing some time ago that you can create a batch file that can be run each night to delete all of the BAK files on the server each night before our backup routine is run to cut down on the size of the backup. It would need to be able to delete files in the subfolders on our Projects server.
    I feel like this should be a very simple thing, but not having the background with batch files makes the websites I've found dealing with them a bit confusing.


    Can anyone help??

    Thanks in advance!!!
    Yep. No problems.

    Change to the drive you want the bak files deleted from e.g. T:

    Batch file should read

    t:
    cd\
    Echo Now eleting all BAK files on drive T:
    del *.bak /s /a


    That's about it

    Or you could run a find/search on the drive in question. CTRL-A then press the del key.

    HTH

    Robert Aitken
    Last edited by RobertAitken; 2005-03-29 at 01:02 PM.

  3. #3
    100 Club jsr13's Avatar
    Join Date
    2004-09
    Location
    Virginia - USA
    Posts
    130

    Default Re: Automatically Delete BAK Files

    Ok - I just set up a set of test directories, populated them with BAK files, & created the batch file. I ran it & the files are still there. The prompt was there & gone so quick that I couldn't see what was happening, but the files remain. This is the file:

    \\SPC_SERVER1\Jobs\jeff\test
    cd\
    REM Echo Now eleting all BAK files on \\SPC_SERVER1\Jobs\jeff\test:
    del *.bak /s /a

    Any ideas?

    Jeff Rayhorn

    Sinclair Pratt Cameron, P.C.
    Consulting Structural Engineers
    Virginia Beach
    Virginia, USA

  4. #4
    100 Club Lemons's Avatar
    Join Date
    2001-06
    Location
    Beautiful Charleston, South Carolina
    Posts
    149

    Default Re: Automatically Delete BAK Files

    Quote Originally Posted by jsr13
    Ok - I just set up a set of test directories, populated them with BAK files, & created the batch file. I ran it & the files are still there. The prompt was there & gone so quick that I couldn't see what was happening, but the files remain. This is the file:

    \\SPC_SERVER1\Jobs\jeff\test
    cd\
    REM Echo Now eleting all BAK files on \\SPC_SERVER1\Jobs\jeff\test:
    del *.bak /s /a

    Any ideas?

    Go to your command prompt and type the commands one at a time and see what you get.
    Drop me off in Asheville.

  5. #5
    Certified AUGI Addict rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Houston
    Posts
    7,542

    Default Re: Automatically Delete BAK Files

    Quote Originally Posted by jsr13
    Ok - I just set up a set of test directories, populated them with BAK files, & created the batch file. I ran it & the files are still there. The prompt was there & gone so quick that I couldn't see what was happening, but the files remain. This is the file:

    \\SPC_SERVER1\Jobs\jeff\test
    cd\
    REM Echo Now eleting all BAK files on \\SPC_SERVER1\Jobs\jeff\test:
    del *.bak /s /a

    Any ideas?

    I'm not in front of a M$ network at the moment, but I believe you will have to map a drive letter first. I don't think you can use UNC paths at the command prompt.

    net use Z: \\SPC_SERVER\Jobs\
    ---do you stuff here --
    net use z: /delete

    Let us know....

  6. #6
    100 Club pnorman's Avatar
    Join Date
    2005-02
    Location
    Calgary
    Posts
    179

    Default Re: Automatically Delete BAK Files

    No, the CMD.exe does not support UNC paths! Bummer!

    You can add:
    pause

    to your batch file if you want to see what the window that flashes up faster than you can say "delete my .bak's"
    you will need to be there to "press any key to continue" though so maybe just use it for testing....

    good luck

  7. #7
    100 Club jsr13's Avatar
    Join Date
    2004-09
    Location
    Virginia - USA
    Posts
    130

    Thumbs up Re: Automatically Delete BAK Files

    Ok - tomorrow I'm going to 'pause' the batch file, I'm going to change it to the 'J:' drive (which is where it's mapped), and go through the commands one-by-one.
    I didn't realize that was a limitation of CMD.EXE.
    Will let all of you know how it goes in the morning!
    Last edited by jsr13; 2005-03-30 at 02:28 AM.
    Jeff Rayhorn

    Sinclair Pratt Cameron, P.C.
    Consulting Structural Engineers
    Virginia Beach
    Virginia, USA

  8. #8
    100 Club RobertAitken's Avatar
    Join Date
    2000-10
    Location
    Sunny Scotland
    Posts
    148

    Default Re: Automatically Delete BAK Files

    Jeff,

    Map a drive to the server area (SPC_SERVER1Jobsjefftest) change to that drive and delete the bak files.

    net use Z: SPC_SERVER1Jobsjefftest
    z:
    cd\
    del *.bak /s /a
    :disconnect
    net use z: /d
    if exist z:\*.* goto disconnect


    Sometimes the net use command can throw a wobbly and not disconnect the drive when requested. The loop just makes sure it keeps trying until it has disconnected.

    Hopefully that will work

    Robert

  9. #9
    Active Member rtorres's Avatar
    Join Date
    2002-06
    Location
    Somerset, NJ
    Posts
    86

    Red face Re: Automatically Delete BAK Files

    I would just ...

    Open NOTEPAD and copy & paste this....


    delete c:\my-folder\*.bak
    delete d:\ANOTHER-folder\*.bak
    delete e:\yet-another-folder\*.bak
    delete f:\and-noe-more-folder\*.bak



    Now save it as ...... CLEAN-BAK.BAT ......... in c:\my-folder

    Now go to START> SETTINGS> CONTROL PANEL>SCHEDULED TASKS
    Point to the file and have it run as YOU see fit.

    (Obviously, edit the folder names & drive letters for your use)

    Hope that helps
    Last edited by rtorres; 2005-03-30 at 09:44 AM.
    ... SMILE ... the work will always be there, but you don't have to be there .... try again tomorrow.

  10. #10
    Certifiable AUGI Addict Robert.Hall's Avatar
    Join Date
    2004-07
    Location
    Detroit Michigan
    Posts
    2,510

    Default Re: Automatically Delete BAK Files

    Quote Originally Posted by rtorres
    I would just ...

    Open NOTEPAD and copy & paste this....


    delete c:\my-folder\*.bak
    delete d:\ANOTHER-folder\*.bak
    delete e:\yet-another-folder\*.bak
    delete f:\and-noe-more-folder\*.bak



    Now save it as ...... CLEAN-BAK.BAT ......... in c:\my-folder

    Now go to START> SETTINGS> CONTROL PANEL>SCHEDULED TASKS
    Point to the file and have it run as YOU see fit.

    (Obviously, edit the folder names & drive letters for your use)

    Hope that helps
    Great tip, thanks for posting.

Page 1 of 2 12 LastLast

Similar Threads

  1. Can't open or delete files
    By capstone in forum AutoCAD General
    Replies: 7
    Last Post: 2011-06-20, 03:02 PM
  2. Keep 2012 from automatically convertinging files
    By markleasor in forum Revit Architecture - General
    Replies: 9
    Last Post: 2011-05-07, 01:50 AM
  3. Automatically delete *.BAK, plot.log, acadstk.dmp, and acad.err files
    By CAD Brad in forum CAD Management - General
    Replies: 5
    Last Post: 2009-02-12, 05:41 PM
  4. Automatically jump to opened files
    By lvsuccess in forum AutoCAD General
    Replies: 10
    Last Post: 2008-08-26, 05:35 AM
  5. files swapping information automatically
    By shenderson in forum Revit Architecture - General
    Replies: 11
    Last Post: 2007-03-10, 02:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •