Page 1 of 1
Quick cleaning up desktop from old files
Posted: 26 Jan 2018 05:57
by Jonny
Guys,
Please your kind help with a small batch file that is doing following:
1. Creates a new folder under path : "C:\Users\jonny\xxx\yyy\temp" in format DDMMMYYYY (ex. 26JAN2018)
2. Moving into this new folder all files located on Desktop
That's all..
You help will be much appreciated.
The next phase is to schedule PC to do this automatically.
Re: Quick cleaning up desktop from old files
Posted: 26 Jan 2018 08:41
by Squashman
Re: Quick cleaning up desktop from old files
Posted: 26 Jan 2018 14:41
by Jonny
Is this a joke? Sorry for not having time to learn all the commands.
May someone just help with the solution?
Thanks
Re: Quick cleaning up desktop from old files
Posted: 26 Jan 2018 18:11
by aGerman
Jonny wrote: ↑26 Jan 2018 14:41
Is this a joke? Sorry for not having time to learn all the commands.
DosTips is not RentACoder. So yes, we expect that you take the time to learn Batch as well as you expect that the volunteers take their free time to help you with
your code.
Jonny wrote: ↑26 Jan 2018 14:41
May someone just help with the solution?
Code: Select all
@echo off &setlocal
for %%i in ("01=JAN","02=FEB","03=MAR","04=APR","05=MAY","06=JUN","07=JUL","08=AUG","09=SEP","10=OCT","11=NOV","12=DEC") do set "M%%~i"
for /f "delims=." %%i in ('wmic os get LocalDateTime /value') do for /f %%j in ("%%i") do set "%%j"
set "YYYY=%LocalDateTime:~,4%" &call set "MMM=%%M%LocalDateTime:~4,2%%%" &set "DD=%LocalDateTime:~6,2%"
2>nul md "%userprofile%\xxx\yyy\temp\%DD%%MMM%%YYYY%"
for /f "delims=" %%i in ('dir /b "%userprofile%\desktop\*.*"^|findstr /vie "\.lnk \.url"') do (
move "%userprofile%\desktop\%%i" "%userprofile%\xxx\yyy\temp\%DD%%MMM%%YYYY%\"
)
Steffen
Re: Quick cleaning up desktop from old files
Posted: 26 Jan 2018 18:12
by ShadowThief
Re: Quick cleaning up desktop from old files
Posted: 27 Jan 2018 05:10
by Jonny
Thank you, Steffen, I will try this and let you know.
Re: Quick cleaning up desktop from old files
Posted: 02 Feb 2018 12:31
by Jonny
This looked to me too much complicated, so I've built a new one:
Looks at this , much more readable solution:
Code: Select all
@echo off &setlocal
md "C:\Users\YYY\OneDrive - XXX\Documents\temp\%DATE:~3,2%%DATE:~0,2%%DATE:~8,4%
move "C:\Users\YYY\OneDrive - XXX\Desktop\*.*" "C:\Users\YYY\OneDrive - XXX\Documents\temp\%DATE:~3,2%%DATE:~0,2%%DATE:~8,4%
pause
What's the difference?
Re: Quick cleaning up desktop from old files
Posted: 02 Feb 2018 12:43
by Squashman
Jonny wrote: ↑02 Feb 2018 12:31
This looked to me too much complicated, so I've built a new one:
Looks at this , much more readable solution:
Code: Select all
@echo off &setlocal
md "C:\Users\YYY\OneDrive - XXX\Documents\temp\%DATE:~3,2%%DATE:~0,2%%DATE:~8,4%
move "C:\Users\YYY\OneDrive - XXX\Desktop\*.*" "C:\Users\YYY\OneDrive - XXX\Documents\temp\%DATE:~3,2%%DATE:~0,2%%DATE:~8,4%
pause
What's the difference?
You changed the scope of your request then.
Your original request said to do the date like this.
Jonny wrote: ↑26 Jan 2018 05:57
1. Creates a new folder under path : "C:\Users\jonny\xxx\yyy\temp" in format DDMMMYYYY (ex. 26JAN2018)
Your new code will only work on computers that have the same regional settings as you. The code provided to you is region independent.