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.
Quick cleaning up desktop from old files
Moderator: DosItHelp
Re: Quick cleaning up desktop from old files
Is this a joke? Sorry for not having time to learn all the commands.
May someone just help with the solution?
Thanks
May someone just help with the solution?
Thanks
Re: Quick cleaning up desktop from old files
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.
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%\"
)
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Quick cleaning up desktop from old files
Let me narrow that down for you.
https://ss64.com/nt/md.html
https://ss64.com/nt/move.html
https://stackoverflow.com/a/19741875/4158862
https://ss64.com/nt/md.html
https://ss64.com/nt/move.html
https://stackoverflow.com/a/19741875/4158862
Re: Quick cleaning up desktop from old files
Thank you, Steffen, I will try this and let you know.
Re: Quick cleaning up desktop from old files
This looked to me too much complicated, so I've built a new one:
Looks at this , much more readable solution:
What's the difference?
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
Re: Quick cleaning up desktop from old files
You changed the scope of your request then.Jonny wrote: ↑02 Feb 2018 12:31This looked to me too much complicated, so I've built a new one:
Looks at this , much more readable solution:What's the difference?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
Your original request said to do the date like this.
Your new code will only work on computers that have the same regional settings as you. The code provided to you is region independent.