Re: Need to delete files and folders automatically
From: *Vanguard* (no-email_at_bogus.nix)
Date: 01/29/04
- Next message: *Vanguard*: "Re: Reporting a virus"
- Previous message: *Vanguard*: "Re: How 128-bit encryption?"
- In reply to: anonymous_at_discussions.microsoft.com: "Need to delete files and folders automatically"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 29 Jan 2004 15:26:03 -0600
"anonymous@discussions.microsoft.com" said in
news:6daa01c3e6a8$c6bb1730$a501280a@phx.gbl:
> I need to delete files and folders from a certain
> directory on my server each night. Example, I have
> directory D:\image, in image I use as a tempory storage
> place for scanned images, I want to delete all the files
> and folders in D:\image on nightly basis, but do not want
> to remove the image directory.
>
> I have tried to use the rmdir, del command in DOS to write
> a batch file, but it either removes the Image directory
> (can not allow because it is shared) or it will remove all
> files but not the folders.
>
> Thanks in advance for the information.
So what's the difference between:
- Leaving the directory and deleting everything under it (files and
subdirectories)?
- Or, deleting the directory (and taking out everything under it) and
recreating that directory?
D:
cd \image
rem - Delete files:
for %%i in (*) do del "%%i" > nul
rem - Delete subdirectories:
for /d %% in (*) do rd /s /q "%%i" > nul
The doubled percent sign ("%%") is needed when running the command in a
batch file; at the command prompt, you use just one to designate a
replaceable parameter.
Make sure the parameter is quoted in the del and rd commands since it is
possible the file or subdirectories names may contain spaces.
I checked this on Windows XP but I think the for command under Windows 2000
also supports the /d option. Do "for /?" to see what options it supports on
your OS version.
--
- Next message: *Vanguard*: "Re: Reporting a virus"
- Previous message: *Vanguard*: "Re: How 128-bit encryption?"
- In reply to: anonymous_at_discussions.microsoft.com: "Need to delete files and folders automatically"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|