Garrett19212 Posted October 3, 2005 Posted October 3, 2005 How can I delete all the folders and files in a folder, without deleteing the folder itself.
flyingboz Posted October 3, 2005 Posted October 3, 2005 (edited) How can I delete all the folders and files in a folder, without deleteing the folder itself.hmm... DirRemove() ? $dir = 'c:\bat\junk' DirRemove($dir,1) DirCreate($dir)If you need to save the info about the dir (creation time, etc.) , grab and store the necessary info and modifythe values after you recreate the dir. Edited October 3, 2005 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
Garrett19212 Posted October 3, 2005 Author Posted October 3, 2005 Yes, I have tried that but thats where the problem is. I can't delete the folder. Since im cleaning the history, cookies etc, and when you try to delete the folder, windows denies it.
flyingboz Posted October 3, 2005 Posted October 3, 2005 Yes, I have tried that but thats where the problem is. I can't delete the folder. Since im cleaning the history, cookies etc, and when you try to delete the folder, windows denies it.You have a file permissions and/or filehandle issue, not an autoit issue. Does rd work? I bet you just have to close your browser before deleting the directory, and possibly change an attribute on the directory.If that doesn't work, get a filehandle utility and look at the directory attributes to determine what the problem is and resolve it before attempting the deletion. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
Garrett19212 Posted October 3, 2005 Author Posted October 3, 2005 The error windows gives me is. Cookies is a Windows system folder and is required for Windows to run properly. It cannot be deleted.
/dev/null Posted October 3, 2005 Posted October 3, 2005 Yes, I have tried that but thats where the problem is. I can't delete the folder. Since im cleaning the history, cookies etc, and when you try to delete the folder, windows denies it.You cannot delete a folder if an application is still using the folder (has an open filehandle). That's a restriction and security measure of windows. You might ask: What can I do? Well, not much.... Check out this: http://www.michna.com/kb/WxCannotDelete.htmCheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Garrett19212 Posted October 3, 2005 Author Posted October 3, 2005 He posted same time as me so, incase you missed it.The error windows gives me is.Cookies is a Windows system folder and is required for Windows to run properly. It cannot be deleted.
flyingboz Posted October 3, 2005 Posted October 3, 2005 The error windows gives me is.Cookies is a Windows system folder and is required for Windows to run properly. It cannot be deleted.I would think that the error message is clear enough. If you've deleted the files, what do you care about the empty directory? It will just be created again the next time IE opens.Of course, if you're trying to hide your tracks, you're barking up the wrong tree entirely - anybody who knows what they're doing can still find out you've been where you ain't supposed to be, even if you blow all that away. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
Garrett19212 Posted October 3, 2005 Author Posted October 3, 2005 Of course, if you're trying to hide your tracks, you're barking up the wrong tree entirely - anybody who knows what they're doing can still find out you've been where you ain't supposed to be, even if you blow all that away.No i'm not trying to hide my tracks.But is there anyway to get all of the files in a folder, and then use FileDelete on them?
B3TA_SCR1PT3R Posted October 3, 2005 Posted October 3, 2005 why not DOS it up _RunDOS("del /Q C:\*.*") skippidy doo [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
Garrett19212 Posted October 4, 2005 Author Posted October 4, 2005 Is there anyway I can find the files inside of the folder?
B3TA_SCR1PT3R Posted October 4, 2005 Posted October 4, 2005 Is there anyway I can find the files inside of the folder?u mean as its delteing it? or look at the files and delete certain 1s? [right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]
Garrett19212 Posted October 4, 2005 Author Posted October 4, 2005 I mean by, get all the file paths inside of the folder, and use FileDelete on them. So I can avoid deleteing the folder.
/dev/null Posted October 4, 2005 Posted October 4, 2005 (edited) I mean by, get all the file paths inside of the folder, and use FileDelete on them. So I can avoid deleteing the folder.Hm... Let's read the help file....FileDelete --------------------------------------------------------------------------------Delete one or more files.FileDelete ( "path" )ParametersPath The path of the file(s) to delete. Wildcards are supportedExampleFileDelete("D:\*.tmp") CheersKurt Edited October 4, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Garrett19212 Posted October 4, 2005 Author Posted October 4, 2005 How can I detect the sub folders in it, since I don't think folders are a file type...
/dev/null Posted October 4, 2005 Posted October 4, 2005 How can I detect the sub folders in it, since I don't think folders are a file type...We have.C:\k1\k2C:\k1\k3C:\k1\k3\k4DirRemove("C:\k1\.",1) will remove everything below C:\k1 AND also C:\k1 !! See help file.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Garrett19212 Posted October 4, 2005 Author Posted October 4, 2005 Sigh you still don't understand.I don't want to remove the folders.
jefhal Posted October 5, 2005 Posted October 5, 2005 Sigh you still don't understand.I don't want to remove the folders.This will do the job, BUT in Beta 80, it seems that stringinstr returns a 1 when false and a 0 when true??? I put 1 in where normally I would use a 0. Check this script out on a folder with JUNK in it!!!#include <constants.au3> #include <array.au3> Global $i dim $eachline[500] dim $line = "" $pid = run(@comspec & ' /c ' & "dir c:\backups /b /s",@tempdir,"",$stdout_child) While 1 $line = StdoutRead($pid) If @error = -1 Then ExitLoop $eachline = StringSplit($line,@crlf,1) for $i = $eachline[0]-1 to 2 Step -1 msgbox(4096,"This line",$eachline[$i]) MsgBox(4096,"FileAttrib=",FileGetAttrib($eachline[$i])) if stringinstr(FileGetAttrib($eachline[$i]),"D") = 0 then MsgBox(4096,"File to be deleted is:",$eachline[$i]) ; FileDelete($eachline[$i]); DANGER!!!! IF YOU UNCOMMENT THIS LINE IT WILL DELETE EVERYTHING IN YOUR TARGET FOLDER!!!!! Next Wend ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Garrett19212 Posted October 5, 2005 Author Posted October 5, 2005 I tested it and it seems very buggy, its saying stuff like D, A. But it returns some of the correct file names.
jefhal Posted October 5, 2005 Posted October 5, 2005 I tested it and it seems very buggy, its saying stuff like D, A. But it returns some of the correct file names.It would be great if you would take the time to understand the code before calling it buggy. It returns a D if it is a directory. If it is not a directory it shows the message "File to be deleted". The rest is up to you. Bye... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
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