I everybody im starting now with batch scripting and i nedd to implement a script that :
find for all files "*.log* in folder
after
rename this files with de current date , zip this files and move all files ziper for other folder..
i have these code..
onde batch file with
@echo off
for /f "tokens=*" %%a in ('dir /b *.log') do C:\directory\archive.bat %%a
exit 0
and other
ren %1 %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2% %%a
zip -m %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%.zip %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
move /Y *.zip* "C:directory\log\BCK_ZIP"
pause
but i want put all in only in file..
Can you help me..
when i put
@echo off
for /f "tokens=*" %%a in ('dir /b *.log') do (
ren %1 %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2% %%a
zip -m %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%.zip %1_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
move /Y *.zip* "C:directory\log\BCK_ZIP")
pause
ERROR SYNTAX
Help me !! do condicion in batch
Moderator: DosItHelp
Re: Help me !! do condicion in batch
The %%a is represented in the other batch as %1, just replace %1 with %%a
try it now but this blue %%a i don't know what it should be, may be you wrote it by mistake
@echo off
for /f "tokens=*" %%a in ('dir /b *.log') do (
ren %%a %%a_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2% %%a
zip -m %%a_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%.zip %%a_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
move /Y *.zip* "C:directory\log\BCK_ZIP")
pause
try it now but this blue %%a i don't know what it should be, may be you wrote it by mistake

Re: Help me !! do condicion in batch
Hi!!
TY , but after change what you say when i run this script i recived one message "syntax is not correct" in a lopp that not end..
Can you help me ..i think that is a small problem..
TY , but after change what you say when i run this script i recived one message "syntax is not correct" in a lopp that not end..
Can you help me ..i think that is a small problem..
Re: Help me !! do condicion in batch
Try this: but all date/time inside the loop will be the same, it is only evaluated once - so the first log file will have the same date and time in the name as the last log file.
Code: Select all
@echo off
for /f "tokens=*" %%a in ('dir /b *.log') do (
ren "%%a" "%%~na_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%%~xa"
zip -m "%%~na_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%.zip" "%%~na_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%%~xa"
move /Y "*.zip" "C:directory\log\BCK_ZIP"
)
pause