-Update: + Speedy for date|day|week and compacted|shortened in the code :
@echo off & setlocal enableextensions enabledelayedexpansion & set "_do=Get Day^,Month^,Year^,DayOfWeek"
(set "_ds=0Domingo,1Segunda,2Terca,3Quarta,4Quinta,5Sexta,6Sabado," && for /f "tokens=1-4delims= " %%a in ('wmic Path Win32_LocalTime
^!_do!^|findstr /r [0-9]')do set "_d=0%%a" & set "_m=0%%c" & set "_data=!_d:~-2!_!_m:~-2!_%%~d" & set _x=%%b & for %%x in (!_ds!)do ^
echo/%%x|findstr /blic:!_x! >nul && (set "_s=%%x" & set "_data=!_data!_!_s:~1!")) & set "_backup_file=backup_!_data!.7z" & echo/!_backup_file!
| Results | backup_22_04_2019_Segunda.7z
- Bat • For compose the layout of name of filing cabinet catching the dice of date ( with "0" in front of day/month less than 10) and adding the day of week in the filename
@echo off & @setlocal enabledelayedexpansion
set "_dias_=0-Domingo,1-Segunda,2-Terca,3-Quarta,4-Quinta,5-Sexta,6-Sabado"
for /f "tokens=1-4 delims= " %%a in ('WMIC Path Win32_LocalTime Get Day^,Month^,Year^,DayOfWeek^| findstr /r "[0-9]"') do (
if not %%a geq 10 (set "_data=0%%a") else (set "_data=%%~a")
if not %%c geq 10 (set "_data=!_data: =!0%%c") else (set "_data=!_data: =!%%~c")
set "_data=!_data!%%d" & set "DayOfWeek=%%b"
)
for %%d in (!_dias_!)do for /F %%D in ('echo/!DayOfWeek!') do (
for /f "tokens=1,2delims=-" %%1 in ('echo/%%d') do if "%%D" equ "%%1" set "_data=!_data!_%%2"&&goto :_next_:
)
:_next_:
set _backup_file=backup_!_data!.7z
echo/ !_backup_file!
| Results | backup_22_04_2019_Segunda.7z
Thank you very much. Perfect.
– Eder Silva
Obs. If you want the name of the whole day of the week in lowercase, eh soh edit the variable days.
– It Wasn't Me
Thanks for the tip. The edition is good to do.
– Eder Silva
I wonder if you could help me here: https://answall.com/questions/242536/inclu-tarefa-no-scheduler-tasks-do-windows-via-batch
– Laércio Lopes