epo Posted December 8, 2015 Share Posted December 8, 2015 HiI've batch file (backup.bat). It contains following command :-forfiles /p C:\inetpub\logs\LogFiles\W3SVC1 /m *.log /D -30 /C "cmd /c copy @file D:\Backup\BackupTemp" "C:\Program Files (x86)\7-Zip\7z.exe" a D:\Datacap\Taskmaster_logs\"%DATE:~7,2%.%DATE:~4,2%.%DATE:~10,4%-backup".zip D:\Datacap\Taskmaster_logs\tms.logNow want to translate to au3 file but failed...RunWait(@ComSpec & ' /k'& '"forfiles /p C:\inetpub\logs\LogFiles\W3SVC1 /m *.log /D -30 /C ""cmd /c copy @file D:\Backup\BackupTemp""') RunWait(@ComSpec & ' /k'& '""C:\Program Files (x86)\7-Zip\7z.exe"" a D:\Datacap\Taskmaster_logs\""%DATE:~7,2%.%DATE:~4,2%.%DATE:~10,4%-backup"".zip D:\Datacap\Taskmaster_logs\tms.log')Anyone can translate it to me ? Thx in advance... Link to comment Share on other sites More sharing options...
Kovacic Posted December 8, 2015 Share Posted December 8, 2015 when in doubt... cheat... Take any working script and turn it into binary, then call it from your script. I use this tool a whole lot.. love it. C0d3 is P0etry( ͡° ͜ʖ ͡°) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 8, 2015 Moderators Share Posted December 8, 2015 @epo it would help if you would tell us what part is failing, rather than just a general "it's broke" scenario. The first part of your batch files is basically saying "For all files in path C:\inetpub\logs\LogFiles\W3SVC1 that are older than 30 days and follow the format *.log, copy to D:\Backup\BackupTemp". Is this piece working for you (are the files copied successfully), and it is failing on the zip piece, or is it not even copying the files? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Jefrey Posted December 8, 2015 Share Posted December 8, 2015 You can do this:#include <Process.au3> _RunDOS('forfiles /p C:\inetpub\logs\LogFiles\W3SVC1 /m *.log /D -30 /C "cmd /c copy @file D:\Backup\BackupTemp"') _RunDOS('"C:\Program Files (x86)\7-Zip\7z.exe" a D:\Datacap\Taskmaster_logs\"%DATE:~7,2%.%DATE:~4,2%.%DATE:~10,4%-backup".zip D:\Datacap\Taskmaster_logs\tms.log')Or this (test it first):#include <File.au3> #include <Date.au3> $aFiles = _FileListToArray("C:\inetpub\logs\LogFiles\W3SVC1", "*.log", $FLTA_FILES, True) For $i = 0 To $aFiles[0] ; get file modification date $dLastModified = FileGetTime($aFiles[$i]) $dLastModified = $dLastModified[0] & "/" & $dLastModified[1] & "/" & $dLastModified[2] & " " & $dLastModified[3] & ":" & $dLastModified[4] & ":" & $dLastModified[5] ; gets the date difference $iDateDiff = _DateDiff("D", $dLastModified, _NowCalc()) If $iDateDiff >= 30 Then FileCopy($aFiles[$i], "D:\Backup\BackupTemp\") EndIf Next ShellExecuteWait("C:\Program Files (x86)\7-Zip\&z.exe", "a D:\Datacap\Taskmaster_logs\" & @MDAY & "." & @MON & "." & @YEAR & "-backup.zip D:\Datacap\Taskmaster_logs\tms.log") My stuff Spoiler My UDFs _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS · storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt Link to comment Share on other sites More sharing options...
epo Posted December 9, 2015 Author Share Posted December 9, 2015 @epo it would help if you would tell us what part is failing, rather than just a general "it's broke" scenario. The first part of your batch files is basically saying "For all files in path C:\inetpub\logs\LogFiles\W3SVC1 that are older than 30 days and follow the format *.log, copy to D:\Backup\BackupTemp". Is this piece working for you (are the files copied successfully), and it is failing on the zip piece, or is it not even copying the files? HiYes it's working when running in batch mode (batch.bat)... Link to comment Share on other sites More sharing options...
epo Posted December 9, 2015 Author Share Posted December 9, 2015 (edited) You can do this:#include <Process.au3> _RunDOS('forfiles /p C:\inetpub\logs\LogFiles\W3SVC1 /m *.log /D -30 /C "cmd /c copy @file D:\Backup\BackupTemp"') _RunDOS('"C:\Program Files (x86)\7-Zip\7z.exe" a D:\Datacap\Taskmaster_logs\"%DATE:~7,2%.%DATE:~4,2%.%DATE:~10,4%-backup".zip D:\Datacap\Taskmaster_logs\tms.log')Or this (test it first):#include <File.au3> #include <Date.au3> $aFiles = _FileListToArray("C:\inetpub\logs\LogFiles\W3SVC1", "*.log", $FLTA_FILES, True) For $i = 0 To $aFiles[0] ; get file modification date $dLastModified = FileGetTime($aFiles[$i]) $dLastModified = $dLastModified[0] & "/" & $dLastModified[1] & "/" & $dLastModified[2] & " " & $dLastModified[3] & ":" & $dLastModified[4] & ":" & $dLastModified[5] ; gets the date difference $iDateDiff = _DateDiff("D", $dLastModified, _NowCalc()) If $iDateDiff >= 30 Then FileCopy($aFiles[$i], "D:\Backup\BackupTemp\") EndIf Next ShellExecuteWait("C:\Program Files (x86)\7-Zip\&z.exe", "a D:\Datacap\Taskmaster_logs\" & @MDAY & "." & @MON & "." & @YEAR & "-backup.zip D:\Datacap\Taskmaster_logs\tms.log") 1st script isn't working but 2nd one works... Many many thx... Edited December 10, 2015 by epo Update Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 9, 2015 Moderators Share Posted December 9, 2015 When trying the second suggestion, as an FYI, your For loop $i should begin counting from 1 not 0. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
epo Posted December 10, 2015 Author Share Posted December 10, 2015 When trying the second suggestion, as an FYI, your For loop $i should begin counting from 1 not 0.Yes I chg it, noted & thx... Link to comment Share on other sites More sharing options...
Jefrey Posted December 11, 2015 Share Posted December 11, 2015 When trying the second suggestion, as an FYI, your For loop $i should begin counting from 1 not 0.Thanks! I wrote this directly on the forum reply input, that's why I wrote "test it first" 1st script isn't working but 2nd one works... Many many thx... Nice to know that it was helpful My stuff Spoiler My UDFs _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS · storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now