Results 1 to 12 of 12

Thread: Batch file help

  1. #1
    wol
    wol is offline
    Senior Member
    Join Date
    Jul 2003
    Posts
    489
    Thanks
    0
    Thanked
    0 times in 0 posts

    Batch file help

    Guys,

    I need to empty a shared folder on a server at a regular point every week. Ive had a look at using batch files, but it wont let me empty the folder.

    Any ideas?


    Wol

  2. #2
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    Surely you can create a .bat that goes to the directory you want and does del *.* and stick that into scheduled tasks?

    del *.* /Q will delete files only without asking for confirmation. Enter 'help del' or 'help erase' at the prompt (presumably your using XP?)

    What do you mean, it won't 'let' you?
    Last edited by yamangman; 18-10-2004 at 07:56 PM.
    To err is human. To really foul things up ... you need a computer.

  3. #3
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts
    del /y X:\[directory path]\*.*

    Surely?
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  4. #4
    Will work for beer... nichomach's Avatar
    Join Date
    Jul 2003
    Location
    Preston, Lancs
    Posts
    6,137
    Thanks
    564
    Thanked
    139 times in 100 posts
    • nichomach's system
      • Motherboard:
      • Gigabyte GA-870A-UD3
      • CPU:
      • AMD Phenom II X6 1055T 95W
      • Memory:
      • 16GB DR3
      • Storage:
      • 1x250GB Maxtor SATAII, 1x 400GB Hitachi SATAII
      • Graphics card(s):
      • Zotac GTX 1060 3GB
      • PSU:
      • Coolermaster 500W
      • Case:
      • Coolermaster Elite 430
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Dell 20" TFT
      • Internet:
      • Virgin Media Cable
    del {drive:}\{path}\{folder to be emptied}\*.* /S (specifies removal of all files in subdirectories) /F (force deletion of read-only files) /Q (quiet mode; suppresses confirmation requests)?

    What isn't it letting you clean out?

  5. #5
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts
    Perhaps some of the files are in use? Therefore, maybe he needs to kill the share before deleting the contents of the directory.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  6. #6
    wol
    wol is offline
    Senior Member
    Join Date
    Jul 2003
    Posts
    489
    Thanks
    0
    Thanked
    0 times in 0 posts
    It cleans the files fine with that, but not the subfolders as well! Grr


    EDIT: I should have said that i'd tried that one already.
    Last edited by wol; 19-10-2004 at 08:42 AM.

  7. #7
    Time for Walkies... Atomic's Avatar
    Join Date
    Apr 2004
    Location
    Norfolk, UK
    Posts
    1,959
    Thanks
    0
    Thanked
    0 times in 0 posts
    I'd do it throught a VBScript.

    The DeleteFile & DeleteFolder methods would work fine. Get it to list the folder contents first and apply the correct method to each.

  8. #8
    TiG
    TiG is offline
    Walk a mile in other peoples shoes...
    Join Date
    Jul 2003
    Location
    Questioning it all
    Posts
    6,213
    Thanks
    43
    Thanked
    47 times in 42 posts
    rmdir? and mkdir?

    TiG
    -- Hexus Meets Rock! --

  9. #9
    Time for Walkies... Atomic's Avatar
    Join Date
    Apr 2004
    Location
    Norfolk, UK
    Posts
    1,959
    Thanks
    0
    Thanked
    0 times in 0 posts
    It wont be shared if the folder is deleted then remade.

  10. #10
    wol
    wol is offline
    Senior Member
    Join Date
    Jul 2003
    Posts
    489
    Thanks
    0
    Thanked
    0 times in 0 posts
    Grrr this should be nice and simple, might have to see if i can make a program using my old Delphi skills

  11. #11
    Ex-MSFT Paul Adams's Avatar
    Join Date
    Jul 2003
    Location
    %systemroot%
    Posts
    1,926
    Thanks
    29
    Thanked
    77 times in 59 posts
    • Paul Adams's system
      • Motherboard:
      • Asus Maximus VIII
      • CPU:
      • Intel Core i7-6700K
      • Memory:
      • 16GB
      • Storage:
      • 2x250GB SSD / 500GB SSD / 2TB HDD
      • Graphics card(s):
      • nVidia GeForce GTX1080
      • Operating System:
      • Windows 10 x64 Pro
      • Monitor(s):
      • Philips 40" 4K
      • Internet:
      • 500Mbps fiber
    3-line batch file:

    Code:
    x:
    cd \path_to_folder\whose_contents\to_delete
    rd /s /q \path_to_folder\whose_contents\to_delete
    As the current working directory of the process is the folder you are trying to delete, it fails (as designed), but only after deleting all files and sub-folders within.

    Replace x: with the appropriate drive letter.

    Schedule this batch file to run locally on the server at the required time, and you're done.
    ~ I have CDO. It's like OCD except the letters are in alphabetical order, as they should be. ~
    PC: Win10 x64 | Asus Maximus VIII | Core i7-6700K | 16GB DDR3 | 2x250GB SSD | 500GB SSD | 2TB SATA-300 | GeForce GTX1080
    Camera: Canon 60D | Sigma 10-20/4.0-5.6 | Canon 100/2.8 | Tamron 18-270/3.5-6.3

  12. #12
    wol
    wol is offline
    Senior Member
    Join Date
    Jul 2003
    Posts
    489
    Thanks
    0
    Thanked
    0 times in 0 posts
    cool cheers ill give it a go

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 63
    Last Post: 14-11-2011, 09:17 AM
  2. How do you backup?
    By Howard in forum PC Hardware and Components
    Replies: 48
    Last Post: 05-01-2005, 09:05 AM
  3. Graphics file format jpeg & WinXP paint...
    By retroborg in forum Graphics Cards
    Replies: 2
    Last Post: 21-07-2004, 09:26 PM
  4. Manage downloaded webpages file and folder
    By Zathras in forum Software
    Replies: 0
    Last Post: 17-09-2003, 05:37 PM
  5. Replies: 0
    Last Post: 20-08-2003, 11:42 AM

Posting Permissions

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