Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set filename=%date:~6,4%%date:~0,2%%date:~3,2%_%time:~0,2%24%time:~3,2%%time:~6,2%_backup.log
- echo "some new data" >> %filename%
- ipconfig /all >> %filename%
- REM SET YEAR
- set YEAR=%date:~6,4%
- REM SET MONTH
- set MONTH=%date:~3,2%
- if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
- if %MONTH% LSS 10 set MONTH=0%MONTH%
- REM SET DAY
- set DAY=%date:~0,2%
- if %DAY% LSS 10 set DAY=%DAY:~1,2%
- if %DAY% LSS 10 set DAY=0%DAY%
- REM SET HOUR
- set HOUR=%time:~0,2%
- if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
- if %HOUR% LSS 10 set HOUR=0%HOUR%
- REM SET MINUTE
- set MINUTE=%time:~3,2%
- if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
- if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
- REM SET SECOND
- set SECOND=%time:~6,2%
- if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
- if %SECOND% LSS 10 set SECOND=0%SECOND%
- set filename=%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%.log
- REM SET YEAR
- set YEAR=%date:~6,4%
- REM SET MONTH
- set MONTH=%date:~3,2%
- if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
- if %MONTH% LSS 10 set MONTH=0%MONTH%
- REM SET DAY
- set DAY=%date:~0,2%
- if %DAY% LSS 10 set DAY=%DAY:~1,2%
- if %DAY% LSS 10 set DAY=0%DAY%
- REM SET HOUR
- set HOUR=%time:~0,2%
- if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
- if %HOUR% LSS 10 set HOUR=0%HOUR%
- REM SET MINUTE
- set MINUTE=%time:~3,2%
- if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
- if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
- REM SET SECOND
- set SECOND=%time:~6,2%
- if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
- if %SECOND% LSS 10 set SECOND=0%SECOND%
- set filename=%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%.log
- REM get a date time for a logfile name
- REM If the echo %time% does not return a 24 hr time on the target OS / region settings,
- REM You will need to do something like
- REM set %ampm%=%time:~9,2%
- REM if "%ampm%" EQU "PM" set /a hour=hour+12
- REM testcase 1 with months, hours, mins, etc, less than 10.
- REM Make sure to test with a format matches what your OS/regional settings will produce
- REM test data should match the output from "for /f "tokens=1,2" %%u in ('date /t') do set d=%%v"
- REM and for /f "tokens=1" %%u in ('echo %time%') do set t=%%u
- REM set d=01/02/2009
- REM set t=3:04:05.06
- REM testscase 2 with full width month, hours, mins, etc.
- REM Make sure to test with a format matches what your OS/regional settings would produce in this case.
- REM set d=10/20/2009
- REM set t=10:20:30.40
- REM if not testing, use the real date and time:
- REM
- REM the next line grabs the second (space) delimited thing from 'date /t', trims up spaces, and stores it in d
- for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
- REM this times up the spaces from 'time'
- for /f "tokens=1" %%u in ('echo %time%') do set t=%%u
- if "%t:~1,1%"==":" set t=0%t%
- echo d has the value: "%d%"
- echo t has the value: "%t%"
- REM @echo off
- set hour=%t:~0,2%
- if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
- set min=%t:~3,2%
- set secs=%t:~6,2%
- set year=%d:~-4%
- set month=%d:~0,2%
- set day=%d:~3,2%
- echo year=%year%,month=%month%,day=%day%,hour=%hour%,min=%min%,secs=%secs%
- set datetimePartOfFile=%year%%day%%month%_%hour%24%min%%secs%
- echo %datetimePartOfFile%
- set filename=%datetimePartOfFile%_backup.log
- echo %filename%
- ren logfile.log %filename%
- for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
- for /f "tokens=1" %%u in ('echo %time%') do set t=%%u
- if "%t:~1,1%"==":" set t=0%t%
- set hour=%t:~0,2%
- set min=%t:~3,2%
- set secs=%t:~6,2%
- set year=%d:~-4%
- set month=%d:~0,2%
- set day=%d:~3,2%
- set datetimePartOfFile=%year%%day%%month%_%hour%24%min%%secs%
- set filename=%datetimePartOfFile%_backup.log
- ren logfile.log %filename%
- @echo off
- set DT1=%date:~6,4%%date:~3,2%%date:~0,2%
- set TIME1=%time:~0,8%
- set TIME1=%TIME1::=%
- set FILENAME1=%DT1%_%TIME1%
- @echo test %FILENAME1%
- @echo off
- set fileName=Nome do seu arquivo
- set extension=xls
- set destination=C:/Users/Chunda/Dropbox
- set ano=%date:~6,4%
- set mes=%date:~3,2%
- set dia=%date:~0,2%
- set hora=%time:~0,2%
- set minuto=%time:~3,2%
- set segundo=%time:~6,2%
- set backupName=_%ano%-%mes%-%dia%_%hora%h%minuto%m%segundo%s
- set commandString="%fileName%.%extension%" "%destination%%fileName%%backupName%.%extension%"
- copy %commandString%
- echo %fileName%.%extension%
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement