Batch: Clean Desktop

@echo off

REM moves graphic files to "Screenshots", other files to folder "_Desktop<timestamp>
REM demonstrates current date/time stamps AND "for (each) loops

setlocal
rem set debug=anythingbutblank
pushd %userprofile%\Desktop
if not exist Screenshots md Screenshots
:makedir with timestamp
set xtime=%time::=%
set xtime=%xtime:.=_%
set xdate=%date: =_%
set xdate=%xdate:/=_%
rem set xdate=%xdate:~4%
set xtime=%xtime:~0,-3%
rem set timestamp=%xdate%_%xtime%
set timestamp=%xdate%
set newdir=_Desktop_%timestamp%
if not "%debug%"=="" @echo on
if not exist %newdir% md %newdir%
rem excluded LNK URL
if not "%debug%"=="" echo newdir is: %newdir%
rem for %%x in (*.url *.lnk *.jpg *.pdf *.txt *.bak *.ahk *.doc* *.sql *.xls* *.png *.xml *.bmp *.gif *.log *.rtf *.htm? *.msg *.zip) do if exist "%%x" move "%%x" %newdir%
for %%x in ( *.csv *.txt *.vsd *.css *.cs *.cpp *.bak *.php *.js *.json *.doc* *.sql *.xls* *.xml *.java *.py *.log *.rtf *.htm? *.msg *.eml *.gz *.zip) do if exist "%%x" move /-Y "%%x" %newdir%
for %%x in ( *.jpg *.pdf *.png *.bmp *.gif ) do if exist "%%x" move /-Y "%%x" Screenshotsif not exist Shortcuts md Shortcutsfor %%x in ( *.lnk *.URL ) do if exist "%%x" move /-Y "%%x" Shortcuts

:set n
:set x
echo end batch file %0
pause

endlocal