Hi Bryce,

I am using your script and I want to delete the files in some folders. I find your script is great. I have make a little change in your script such that I can del the "recent" and "favorites" files in user profiles, like this

change %temp% ==> %userprofile%
and I use a variable, say, $fav and $rec
$fav = %userprofile% + "\favorites"
$rec = %userprofile% + "\recent"

But it is not the main point, I want to says is the first time the script run excellent. When I run the second time, so no file or directory in it, the script continue to loop and did not stop.

Thanks for your concern!

Gilbert Ng

------------------------------------------
break on cls

$tempdir = "temp1.dat"
$tempfile = "temp2.dat"
dim $tempdir_data[99999]

:wrong
? "This will Delete all files and Directories in"
? "%temp%!!! are you sure?(y/n)"
get $yn
select
case lcase($yn) = "y"
;run rest of code
case lcase($yn) = "n"
exit
case 1
goto wrong
endselect


shell "%comspec% /c dir %temp% /ad /b /s > $tempdir"
shell "%comspec% /c dir %temp% /a-d /b /s > $tempfile"

? "Deleting the files in %temp%" gosub kill_files
? "Removing all Directories in %temp%" gosub Kill_directories

del $tempdir
del $tempfile
exit


;----------------------------
:Kill_Files
;----------------------------

$q = open(1,$tempfile)
$tempfile_data = readline(1)
while @error = 0
del $tempfile_data
$tempfile_data = readline(1)
loop
$q = close(1)
return

;----------------------------
:Kill_directories
;----------------------------
$array_count = 0
$q = open (1,$tempdir)
$tempdir_data[$array_count] = readline(1)

while $tempdir_data[$array_count] <> ""
$array_count = $array_count + 1
$tempdir_data[$array_count] = readline(1)
loop
$q = close(1)

rd $tempdir_data[$array_count]
while $array_count >= 0
rd $tempdir_data[$array_count]
$array_count = $array_count - 1
loop
return
-------------------------------------------