Jump to content

delete folders without knowing the name?


fox_91
 Share

Recommended Posts

i am writing a script for my job that goes thru a whole bunch of user's mail folders and deletes all the files, if they have a forward.ima file in it... and not deleting if they don't..... the file deleting i have, but the problem i have is that some of the folders have folders in them, and the delete command doesn't touch the folders.... the delete directory command doesn't seem to support wildcards and i wouldn't know the name of the folder when its automating.. does anyone know how to maybe delete a dir without knowing its name? here is the code i have so far, that does everything i need except del folders when they are there.

GLOBAL $log = "C:\emailclean\log.txt"

GLOBAL $names = "C:\emailclean\names.txt"

GLOBAL $pathtonames ="c:\emailclean\"

GLOBAL $namesinfile = 5

FileOpen("c:\emailclean\log.txt", 2)

FileOpen("c:\emailclean\names.txt", 0)

for $i = 1 to $namesinfile

$path = Filereadline($names, $i)

;Filewriteline($log, $path)

if fileexists($pathtonames & $path & "\forward.ima") Then

filecopy($pathtonames & $path & "\forward.ima", "c:\emailclean\")

filedelete($pathtonames & $path & "\*.*")

DirRemove($pathtonames & $path & "\*" , 1) DEL COMMAND WOULD GO HERE

Filewriteline($log, "files deleted for " & $path)

filecopy("c:\emailclean\forward.ima", $pathtonames & $path & "\forward.ima")

Filewriteline($log, "forward.ima copied back for " & $path)

Else

Filewriteline($log, "forward.ima does NOT EXIST for " & $path)

EndIf

Next

simple but effective.... thanks for any help anyone can provide

Link to comment
Share on other sites

If you search the Scraps and Scripts forum for "recursive folder search" you will find loads of examples that you can change to suit your needs.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

check out my *XPClean Menu* in

1

Scripts and Scrapts for full au3 and explination

2

my *XPClean Menu* Website below for full explination and exe

3

check out my hobby site below for the most current au3

at the middle lower portion i have a function just for that

also you could just use the program and CCleaner (included) you can set customized folders to clean-out

good luck

8)

NEWHeader1.png

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...