Jump to content

Recommended Posts

Posted

Making the assumption we're talking about a windows machine, then try:

 

del d:\folders-you-want-to-empty-just-files-from\*.* /s /f /q

 

where d: etc is the location of the root folder you want to clear... Think it's v.similar in Swahili!

Posted
Please can somone isnstruct me on a script that will empty the contents of a folder but not the folders itself.

 

Cheers

 

Hi

 

the command that tonyd posted will only delete files, i need it to delete folders as well.

 

Thnaks for your help

 

Z

 

 

Sorry Z, but I'm confused - you OP states you only want to delete the files, which means tonyd's Command works.. (deletes all files but no folders)

 

But then you say you want to delete the folders too?

 

If you want to delete all subfolders, but not the root try this:

@echo off
pushd %1
del /q *.* 
for /f "Tokens=*" %%G in ('dir /B') do rd /s /q "%%G"
popd 

 

taken from here

  • 1 month later...
Posted

Still haven't got round to doing this

 

"Sorry Z, but I'm confused - you OP states you only want to delete the files, which means tonyd's Command works.. (deletes all files but no folders)"

 

In my post it says delete the contents of a folder but not the folder itself, sorry for the confusion.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 46 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...