FN-GM Posted January 23, 2008 Report Posted January 23, 2008 Please can somone isnstruct me on a script that will empty the contents of a folder but not the folders itself. Cheers
tonyd Posted January 23, 2008 Report Posted January 23, 2008 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!
FN-GM Posted January 23, 2008 Author Report Posted January 23, 2008 .bat wouls be best please i can't get this one to work del C:\New Folder\*.* /s /f /q Z
webman Posted January 23, 2008 Report Posted January 23, 2008 Try enclosing the path with quotes - spaces confuses CMD.exe.
FN-GM Posted January 23, 2008 Author Report Posted January 23, 2008 Ok thanks i will give that ago tomorrow. Z
FN-GM Posted January 29, 2008 Author Report Posted January 29, 2008 Hi the command that tonyd posted will only delete files, i need it to delete folders as well. Thnaks for your help Z
Gatt Posted January 29, 2008 Report Posted January 29, 2008 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
FN-GM Posted March 12, 2008 Author Report Posted March 12, 2008 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.
bizzel Posted March 12, 2008 Report Posted March 12, 2008 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 1
FN-GM Posted March 12, 2008 Author Report Posted March 12, 2008 thanks but i get Error 404 - Not Found. Z
bizzel Posted March 12, 2008 Report Posted March 12, 2008 Just uploaded it now. Needs .Net 2.0 to be installed btw. You'll probably have it already. 1
FN-GM Posted March 12, 2008 Author Report Posted March 12, 2008 Thanks alot mate, will take a look at that tomorrow. Z
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now