Computing.Net > Forums > Programming > Batch to Delete files in a folder

Batch to Delete files in a folder

Reply to Message Icon

Original Message
Name: Frankie566
Date: March 12, 2008 at 16:36:53 Pacific
Subject: Batch to Delete files in a folder
OS: WinXP & Win2KPro
CPU/Ram: Xeon240Ghz,2.39Ghz/1
Model/Manufacturer: CompaqProliantML350/
Comment:

Hello,
I’m trying to make a bat file that will delete all files in the My Pictures and the My Music folders for a particular user. This should work for both WinXP and Win2000Pro machines.

See, we have a public computer lab in our library and all of people using these public computers use the same user name, which is: “All”.

What I want is to do is to delete any file saved in the My Pictures and My Music folders regardless of what time, date, or type file they are. I want to completely empty the folders for that user.

The path to the folders are:
C:\Documents and Settings\All\My Documents\My Pictures\

C:\Documents and Settings\All\My Documents\My Music\

After I have the batch file created I will then copy it to the PCs and have it run as a scheduled task daily. That way, keep the folder clean of their leftovers.

Any help will be appreciated, Thank You!
Frankie

So far this is what I have:

@ECHO OFF
REM
REM Deletes any file in the specified folders
REM
REM This is for this Local Computer Only
REM
CLS
:BEGIN

del C:\Documents and Settings\all\My Documents\My Pictures\*.* /S
REM
del C:\Documents and Settings\all\My Documents\My Music\*.* /S

REM
REM End of this file
REM

:END
EXIT

Who knows, knows and who doesn't know, dosen't know jack!
El que sabe, sabe y el que no sabe, no sabe nada!


Report Offensive Message For Removal


Response Number 1
Name: Razor2.3
Date: March 12, 2008 at 17:36:31 Pacific
Reply: (edit)

As much as I dislike it when people ignore the scripting question asked, I must say there are better options available.

@DEL /S /Q /F "C:\Documents and Settings\all\My Documents\My Music\*.*"
@DEL /S /Q /F "C:\Documents and Settings\all\My Documents\My Pictures\*.*"


Report Offensive Follow Up For Removal

Response Number 2
Name: Frankie566
Date: March 13, 2008 at 09:34:19 Pacific
Reply: (edit)

Razor2.3 Thank You for your help. I will try it and post back.
Frankie

Who knows, knows and who doesn't know, dosen't know jack!
El que sabe, sabe y el que no sabe, no sabe nada!


Report Offensive Follow Up For Removal

Response Number 3
Name: Frankie566
Date: March 14, 2008 at 06:28:29 Pacific
Reply: (edit)

Razor,
I tested it on one computer and it worked perfectly. Thank You very much.

Next, I put the batch file on the server and added it as a scheduled task on on all Public Computer Lab PCs to run at Daily at the end of the day.

Who knows, knows and who doesn't know, dosen't know jack!
El que sabe, sabe y el que no sabe, no sabe nada!


Report Offensive Follow Up For Removal

Response Number 4
Name: klint
Date: March 15, 2008 at 15:39:18 Pacific
Reply: (edit)

I fail to see what the use is of deleting all the files in My Pictures and My Music folders. There is nothing stopping people adding music and pictures in folders with different names, and the above batch file won't touch those. That's why Razor's suggestion of using Windows SteadyState is better.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch to Delete files in a folder

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge