Forum Home
Press F1
 
Thread ID: 131274 2013-04-30 22:13:00 script to delete files and folder in windows server Gobe1 (6290) Press F1
Post ID Timestamp Content User
1339074 2013-04-30 22:13:00 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
Gobe1 (6290)
1339075 2013-04-30 22:29:00 rmdir? technet.microsoft.com Agent_24 (57)
1339076 2013-04-30 22:47:00 rmdir? technet.microsoft.com

Unfortunately we dont know what the directory names are so this wont work and you cant use *
Gobe1 (6290)
1339077 2013-04-30 23:49:00 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 ??
1101 (13337)
1339078 2013-04-30 23:55:00 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
Gobe1 (6290)
1339079 2013-05-01 01:06:00 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
1101 (13337)
1339080 2013-05-01 02:13:00 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
Gobe1 (6290)
1339081 2013-05-01 02:30:00 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
1101 (13337)
1339082 2013-05-01 03:21:00 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 Gobe1 (6290)
1339083 2013-05-01 03:32:00 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


:-)
1101 (13337)
1 2