FN-GM (13th March 2008)

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

What language?

Ooh! Choice. Swahili please![]()
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!

.bat wouls be best please
i can't get this one to work
del C:\New Folder\*.* /s /f /q
Z

Try enclosing the path with quotes - spaces confuses CMD.exe.

Ok thanks i will give that ago tomorrow.
Z

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:
taken from hereCode:@echo off pushd %1 del /q *.* for /f "Tokens=*" %%G in ('dir /B') do rd /s /q "%%G" popd

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.
Here you go. Something to remove all files and subfolders from a given folder. Just give it the path as "X:\whatever\foo\bar" and away you go. It was done in 5 minutes flat so it's not my finest code. It's quite safe though, it won't go and trash your folders. Promise. See if it does the trick.
http://www.paulbeesley.com/wp-content/uploads/quickclear.zip
FN-GM (13th March 2008)

thanks but i get Error 404 - Not Found.
Z
Just uploaded it now. Needs .Net 2.0 to be installed btw. You'll probably have it already.
FN-GM (13th March 2008)

Thanks alot mate, will take a look at that tomorrow.
Z
There are currently 1 users browsing this thread. (0 members and 1 guests)