Made a folder cleaner with batch

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Made a folder cleaner with batch

Post by ayu »

I made a folder cleaner for a friend, and i used batch just for the fun of it, just one problem that i encountered. That the file "index.dat" can't be deleted during windows run. Is there any way to delete it?...i made it so that it is copied from the cookies folder, and backuped then placed in the folder again when it has been cleaned. But it can't be deleted =/ ...can't i delete it if i add the batch file to services or something?

Code: Select all

@echo off
echo Deleting prefetch
DEL /Q "C:/windows/prefetch"
echo Done!
if exist "C:/windows/prefetch" goto folderexists
echo A folder was not created, creating new prefetch folder
MD "C:/windows/prefetch"
echo Done!
:folderexists
echo Deleting temp folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala inställningar\Temp"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala inställningar\Temp" goto tempexists
echo A folder was not created, creating new temp folder
MD "C:\Documents and Settings\Nemo\Lokala inställningar\Temp"
echo Done!
:tempexists
echo Deleting Temporary Internet Files
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala inställningar\Temporary Internet Files"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala inställningar\Temporary Internet Files" goto tempie
echo A folder was not created, creating new Temporary Internet Files folder
MD "C:\Documents and Settings\Nemo\Lokala inställningar\Temporary Internet Files"
echo Done!
:tempie
echo Deleting the "Tidigare" folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala inställningar\Tidigare"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala inställningar\Tidigare" goto tidigarex
echo A folder was not created, creating new Tidigare folder
MD "C:\Documents and Settings\Nemo\Lokala inställningar\Tidigare"
echo Done!
:tidigarex
echo Deleting cookies folder
@echo off
COPY "C:\Documents and Settings\Nemo\Cookies\index.dat" "C:\windows"
DEL /Q "C:\Documents and Settings\Nemo\Cookies"
echo Done!
if exist "C:\Documents and Settings\Nemo\Cookies" goto cookiesx
echo A folder was not created, creating new Cookies folder
MD "C:\Documents and Settings\Nemo\Cookies"
echo Done!
:cookiesx
COPY "C:\windows\index.dat" "C:\Documents and Settings\Nemo\Cookies\"
DEL /Q "C:\windows\index.dat"
echo Deleting Recent folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Recent"
echo Done!
if exist "C:\Documents and Settings\Nemo\Recent" goto recentx
echo A folder was not created, creating new Recent folder
MD "C:\Documents and Settings\Nemo\Recent"
echo Done!
:recentx
echo Deleting Flash shared objects
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects"
echo Done!
if exist "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects" goto fshx
echo A folder was not created, creating new Flash shared objects folder
MD "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects"
echo Done!
:fshx
pause
EDIT: Solved it, seems like it deletes the files anyway and ignores the index.dat. Also i solved a problem with "åäö", it ignores them so i can't create the folder "lokala inställningar" i have to write "lokala instllningar"

Code looks like this now

Code: Select all

@echo off
echo Deleting prefetch
DEL /Q "C:/windows/prefetch"
echo Done!
if exist "C:/windows/prefetch" goto folderexists
echo A folder was not created, creating new prefetch folder
MD "C:/windows/prefetch"
echo Done!
:folderexists
echo Deleting temp folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala instllningar\Temp"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala instllningar\Temp" goto tempexists
echo A folder was not created, creating new temp folder
MD "C:\Documents and Settings\Nemo\Lokala instllningar\Temp"
echo Done!
:tempexists
echo Deleting Temporary Internet Files
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala instllningar\Temporary Internet Files"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala instllningar\Temporary Internet Files" goto tempie
echo A folder was not created, creating new Temporary Internet Files folder
MD "C:\Documents and Settings\Nemo\Lokala instllningar\Temporary Internet Files"
echo Done!
:tempie
echo Deleting the "Tidigare" folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Lokala instllningar\Tidigare"
echo Done!
if exist "C:\Documents and Settings\Nemo\Lokala instllningar\Tidigare" goto tidigarex
echo A folder was not created, creating new Tidigare folder
MD "C:\Documents and Settings\Nemo\Lokala instllningar\Tidigare"
echo Done!
:tidigarex
echo Deleting cookies folder
@echo off
COPY "C:\Documents and Settings\Nemo\Cookies\index.dat" "C:\windows"
DEL /Q "C:\Documents and Settings\Nemo\Cookies"
echo Done!
if exist "C:\Documents and Settings\Nemo\Cookies" goto cookiesx
echo A folder was not created, creating new Cookies folder
MD "C:\Documents and Settings\Nemo\Cookies"
echo Done!
:cookiesx
COPY "C:\windows\index.dat" "C:\Documents and Settings\Nemo\Cookies\"
DEL /Q "C:\windows\index.dat"
echo Deleting Recent folder
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Recent"
echo Done!
if exist "C:\Documents and Settings\Nemo\Recent" goto recentx
echo A folder was not created, creating new Recent folder
MD "C:\Documents and Settings\Nemo\Recent"
echo Done!
:recentx
echo Deleting Flash shared objects
@echo off
DEL /Q "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects"
echo Done!
if exist "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects" goto fshx
echo A folder was not created, creating new Flash shared objects folder
MD "C:\Documents and Settings\Nemo\Application Data\Macromedia\Flash Player\#SharedObjects"
echo Done!
:fshx
pause 
"The best place to hide a tree, is in a forest"

Post Reply