|
Answer» I just want to know if this is possible with a bath file.
I have 12 txt files that I want to copy (This is working) renaming them in new folder (this is working) But not all of them change every day, so how can I only let the files that I change today, be copied to new folder, and the others that have not changed and have yesterday date. not copied to folder.
I some ot the code from somwere else.
Here are some of the code
Code: [Select]@echo off for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" pause rem Windows GP call :check_copy "D:\Users\hbezuidenhout\Documents\Windows GP Restore.txt" "D:\Users\hbezuidenhout\Documents\WindowsGP\Restore\Windows GP Restore %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows GP Clients.txt" "D:\Users\hbezuidenhout\Documents\WindowsGP\Clients\Windows GP Clients %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows GP Backup.txt" "D:\Users\hbezuidenhout\Documents\WindowsGP\Backup\Windows GP Backup %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows GP Tapes.txt" "D:\Users\hbezuidenhout\Documents\WindowsGP\Tapes\Windows GP Tapes %DD% %MM% %YYYY%.txt" rem Windows VM call :check_copy "D:\Users\hbezuidenhout\Documents\Windows VM Restore.txt" "D:\Users\hbezuidenhout\Documents\WindowsVM\Restore\Windows VM Restore %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows VM Clients.txt" "D:\Users\hbezuidenhout\Documents\WindowsVM\Clients\Windows VM Clients %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows VM Backup.txt" "D:\Users\hbezuidenhout\Documents\WindowsVM\Backup\Windows VM Backup %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Windows VM Tapes.txt" "D:\Users\hbezuidenhout\Documents\WindowsVM\Tapes\Windows VM Tapes %DD% %MM% %YYYY%.txt" rem Unix call :check_copy "D:\Users\hbezuidenhout\Documents\Unix Restore.txt" "D:\Users\hbezuidenhout\Documents\Unix\Restore\Unix Restore %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Unix Clients.txt" "D:\Users\hbezuidenhout\Documents\Unix\Clients\Unix Clients %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Unix Backup.txt" "D:\Users\hbezuidenhout\Documents\Unix\Backup\Unix Backup %DD% %MM% %YYYY%.txt" call :check_copy "D:\Users\hbezuidenhout\Documents\Unix Tapes.txt" "D:\Users\hbezuidenhout\Documents\Unix\Tapes\Unix Tapes %DD% %MM% %YYYY%.txt"
goto :EOF
:check_copy :: gets the LAST modified timestamp in VARIABLES :: file timestamp MMDDYYYY_HHMMSS :: syntax: getfiledate.bat "c:\path\file.exe" @echo off set "file=%~1" set "file=%file:\=\\%" WMIC DATAFILE WHERE name="%file%" get lastmodified | find "." >file.tmp for /f %%a in (file.tmp) do set dt=%%a set dt=%dt:~0,8%_%dt:~8,6% set "lastmod=%dt:~0,8%" del file.tmp
if "%lastmod%" NEQ "%MM%%DD%%YYYY%" ( MD "%~dp2" 2>nul echo copying file "%~2" copy /y "%~1" "%~2" >nul echo DONE ) goto :EOF
When I RUB this it dows not do what I newed it to do.
And I don't have these files
Code: [Select]:: syntax: getfiledate.bat "c:\path\file.exe"I recognise that code.Quote from: foxidrive on October 03, 2013, 06:19:45 AM I recognise that code.
|