Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Senior Member Gobe1's Avatar
    Join Date
    Jun 2008
    Location
    New Plymouth
    Posts
    4,649

    Default script to delete files and folder in windows server

    HI, we have moved from linux to windows servers (why? i know... i know)
    we had scripts to clean out scan folders daily and linux was easy in this area with the rm command

    Does any one have a script that will do the same in windows server? we can get it to remove all the files even ones in extra folders but not the actual folders themselves without removing the shared scan drive

    It seems crazy we have to resort to batch files in modern windows servers

    So far google hasnt helped much
    Multiplayer games are the Shizz "Theres nothing like killing your mates!" Me

  2. #2
    Computer "Specialist" Agent_24's Avatar
    Join Date
    Dec 2004
    Location
    64 Bitville
    Posts
    14,316

    Default Re: script to delete files and folder in windows server

    Non-system disk or disk error. Replace and strike any key when ready.

  3. #3
    Senior Member Gobe1's Avatar
    Join Date
    Jun 2008
    Location
    New Plymouth
    Posts
    4,649

    Default Re: script to delete files and folder in windows server

    Quote Originally Posted by Agent_24 View Post
    Unfortunately we dont know what the directory names are so this wont work and you cant use *
    Multiplayer games are the Shizz "Theres nothing like killing your mates!" Me

  4. #4
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,154

    Default Re: script to delete files and folder in windows server

    Quote Originally Posted by Gobe1 View Post
    Unfortunately we dont know what the directory names are so this wont work and you cant use *
    we dont know what you are trying to 'clean out' either

    A bit more info needed. What are you trying to delete/clean out & why.
    Nothing 'crazy' about using batch files on modern servers

    What was the batch file/script on the old server ??

  5. #5
    Senior Member Gobe1's Avatar
    Join Date
    Jun 2008
    Location
    New Plymouth
    Posts
    4,649

    Default Re: script to delete files and folder in windows server

    Ok it is a scan shared folder where all the printer scans go for 150 staff
    At the end of the day it is full of pdfs and folders and files as people use it to transfer files around the office
    So rather than go in every morning and delete everything we used to use the linux rm command in a cron job

    Windows server cant do this, we have a batch file which will delete files but the folders poeple have created are left behind

    i could find the old linux script but that is a bit irrelevant

    EDIT: getting 150 engineers to cut and paste is too hard which is why we had the rm cron job
    Multiplayer games are the Shizz "Theres nothing like killing your mates!" Me

  6. #6
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,154

    Default Re: script to delete files and folder in windows server

    Not sure why rd wouldnt work. As long as scans was under another shared folder. Else use the del command
    Lets say the scans are in c:\share\scans (or whatever)

    these may not be 100% correct in syntax.....

    cd\
    rd /s /q c:\share\scans
    md c:\share\scans

    or (possibly not as safe)
    cd\share\scans
    del *.* /s /q

    of course do some testing 1st.

    edit: realized deleting & re-creating a shared folder might be the issue
    Last edited by 1101; 01-05-2013 at 12:13 PM.

  7. #7
    Senior Member Gobe1's Avatar
    Join Date
    Jun 2008
    Location
    New Plymouth
    Posts
    4,649

    Default Re: script to delete files and folder in windows server

    yeap the share is the problem

    I cant believe i may have to put some backup software that will move the files to a linux share and then blow them away lol
    Multiplayer games are the Shizz "Theres nothing like killing your mates!" Me

  8. #8
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,154

    Default Re: script to delete files and folder in windows server

    Why not this, from within the shared scan directory, delete all files & subdirectories
    The actual shared folder will remain, but empty.

    cd\scans
    del *.* /s /q

    or (you'll need to test , syntax possibly wrong)
    del c:\scans\*.* /s /q

    or map the drive as say S:\
    then
    del s:\*.*

    or ?
    del \\scans\*.*

    just things to try...plenty of ways to do this
    Last edited by 1101; 01-05-2013 at 01:39 PM.

  9. #9
    Senior Member Gobe1's Avatar
    Join Date
    Jun 2008
    Location
    New Plymouth
    Posts
    4,649

    Default Re: script to delete files and folder in windows server

    Thanks 1101 we will give them a shot, i never thought about using another pc to delete them from say "S:\*.*" that is mapped to the scan drive
    Multiplayer games are the Shizz "Theres nothing like killing your mates!" Me

  10. #10
    Senior Member 1101's Avatar
    Join Date
    Jan 2008
    Posts
    7,154

    Default Re: script to delete files and folder in windows server

    Be carefull with del *.*
    dont want to del most of the server by mistake. Del within a mapped drive will be the safest

    you can have the server 'see' a mapped drive as well , say S: . Then could run that command from the server


    :-)

Similar Threads

  1. Cant delete folder - Files in use
    By John W in forum PressF1
    Replies: 6
    Last Post: 20-06-2011, 01:02 AM
  2. Batch script to delete old files
    By ronyville in forum PressF1
    Replies: 3
    Last Post: 09-04-2009, 07:02 AM
  3. Replies: 10
    Last Post: 14-03-2007, 02:59 PM
  4. Replies: 10
    Last Post: 09-09-2006, 11:04 AM
  5. Replies: 2
    Last Post: 25-05-2004, 10: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
  •