Batch: Clean Windows Desktop

Runs from any location - moves designated files into a new folder on the desktop  named with  today's date

@echo off
rem DESKCLEAN.BAT MAKES DAILY FOLDER FOR WORKING FILES - UNcomment DEBUGFLAG to troubleshoot / pause
:set debugflag=ANYTHING
:set PAUSEFLAG=ANYTHING
IF NOT "%DEBUGFLAG%"=="" ECHO ON
setlocal
pushd %userprofile%\Desktop
set filestring=*.pdf;*.txt;*.log;*.xls*;*.sql;*.bak;*.java;*.class;*.jp*;*.gif;*.png;*.bku;*.bkk;*.bmp;*.htm*;*.php;*.cs;*.pl;*.py;*.rb;*.doc*;*.ppt*

 REM set newdir=_hold_%timestamp% - RATHER THAN HUNT FOR THIS LINE 
rem DEEPER, ASSIGN PREFIX / FOLDER NAME NEXT LINE

 SET DIRPREFIX=

 rem has Day of Week from below "rem set xdate=%xdate:~4%"

rem makedir with timestamp - the source for the odd string manipulators below is cmd's "help for" and "help if"

: below - remove in sequence, colon, period, space, slash (replace
 rem with underscore) then last two remove trailing 1/100ths of second and leading day of week
:xtime not used

set xtime=%time::=%
set xtime=%xtime:.=_%
set xtime=%xtime: =0%
set xtime=%xtime:~0,-3%
set xdate=%date: =_%
set xdate=%xdate:/=_%
rem set xdate=%xdate:~4%
set timestamp=%xdate%

 rem set newdir=_%timestamp%
set newdir=%DIRPREFIX%%timestamp%
 rem set newdir=_%timestamp%
 rem remark out above line if you want day of week included at front
rem set timestamp=%xdate%_%xtime% rem this includes timestamp seconds, making unique folder - OMIT to have only one folder per day

for %%x in (%filestring%) do if exist "%%x" if not exist "%newdir%" md "%newdir%"
for %%x in (%filestring%) do if exist "%%x" move "%%x" %newdir%


rem for %%x in (*.tif;*.jpg;*.jpg;*.gif;*.pdf;*.txt;*.log;*.xls*;*.sql;*.bak;*.bku)
 if exist "%%x" if not exist %newdir% md %newdir%
rem for %%x in (*.tif;*.jpg;*.jpg;*.gif;*.pdf;*.txt;*.log;*.xls*;*.sql;*.bak;*.bku)
 if exist "%%x" move "%%x" %newdir%
IF "%DEBUGFLAG%"=="" GOTO END

pause
:END
popd
: UNcomment any below to pause and see variables at work, also (un)comment top line with @echo
:set n
:SET D
:set x
:set f
:set t 
IF NOT "%PAUSEFLAG%"=="" PAUSE

endlocal