Jump to content

batch file that cleans desktop?

- - - - -

  • Please log in to reply
No replies to this topic

#1
BoxCat

BoxCat

    Newbie

  • Members
  • Pip
  • 1 posts
Hello, im trying to make an not rly common thing lol, i need to remove all the desktop icons and folders with the subfolders ofcourse in to a specific folder. i wanna do all this with a single silent batch file :)
here is what i came up with:
@echo off

xcopy /Y %userprofile%\Desktop\*.* %userprofile%\DesktopFiles\  /s /q /f


c:

cd\ 

cd "%userprofile%\Desktop"

dir *.* /b -o:d | find /v "." > \dirs.txt

for /f "tokens=*" %%a in (\dirs.txt) do call :DelFiles "%%a"

del \dirs.txt

exit /b


:DelFiles %1

set Flag=0

if %1=="All Users" set Flag=1

if %1=="Administrator" set Flag=1

if %1=="CurentUser" set Flag=1

if "%Flag%"=="0" (

cd %1

attrib *.* -r /s

cd..

rem change rd %1 /s /q

rem for no confirmation

rd %1 /s

)

del %userprofile%\Desktop\*.* /s /q /f

it does the job, just one lil bad thing: it actually asks me when meets empty folder for Y / N?
and thats annoying, what i should fix in script to make it automatically delete the empty folders and dont ask me for Y/N?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users