2dkot Posted November 18, 2008 Posted November 18, 2008 Hi, all I'm trying to add system time to file name. My target is creating some numbers of log files, and file's name must include time when script starts. I tried this: $time = @MON & "." & @MDAY & "-" & @hour & ":" & @MIN If FileExists ($FullPathFile) Then FileMove( $Path & "\ Logfile.txt", $Path & "\" & $time & " - Logfile.txt") It doesn't work of course. So can I do this? Thanks
Monamo Posted November 18, 2008 Posted November 18, 2008 Hi, all I'm trying to add system time to file name. My target is creating some numbers of log files, and file's name must include time when script starts. I tried this: $time = @MON & "." & @MDAY & "-" & @hour & ":" & @MIN If FileExists ($FullPathFile) Then FileMove( $Path & "\ Logfile.txt", $Path & "\" & $time & " - Logfile.txt") It doesn't work of course. So can I do this? ThanksTake out the colon, it's a character that can't be used in file names. - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
2dkot Posted November 18, 2008 Author Posted November 18, 2008 Take out the colon, it's a character that can't be used in file names.My paths: $Path = "C:\Documents and Settings\blabla\blabla\Logs"$file = "Logfile.txt"$FullPathFile = "C:\Documents and Settings\blabla\blabla\Logs\Logfile.txt"I removed colon, but it is still:Line 13 (File "C:\Documents and Settings\ivanovkv\Рабочий стол\NuggerwithoutIE.au3"):If FileExists ($FullPathFile) Then FileMove( $Path & "\" $file, $Path & "\" & $time & " - Logfile.txt")If FileExists ($FullPathFile) Then FileMove( ^ ERRORError: Error in expression.
Kip Posted November 18, 2008 Posted November 18, 2008 FileMove( $Path & "\" $file, $Path & "\" & $time & " - Logfile.txt") should be: FileMove( $Path & "\" & $file, $Path & "\" & $time & " - Logfile.txt") MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Juvigy Posted November 18, 2008 Posted November 18, 2008 Create another 2 variables and make one = $Path & "\" $file and the other =$Path & "\" & $time & " - Logfile.txt" and visualize them in a msgbox to verify all is fine.That way you will quickly see where you do wrong.
Sky2hawk Posted November 18, 2008 Posted November 18, 2008 This is how I did it -- may not be pretty but it works $F_NAME = String("C:\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\Logged_on_users1"&@YDAY&@MDAY&@HOUR&@MIN&".htm") FileCopy("C:\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\Logged_on_users.htm", $F_NAME,1)
GEOSoft Posted November 18, 2008 Posted November 18, 2008 My paths: $Path = "C:\Documents and Settings\blabla\blabla\Logs" $file = "Logfile.txt" $FullPathFile = "C:\Documents and Settings\blabla\blabla\Logs\Logfile.txt" I removed colon, but it is still: Line 13 (File "C:\Documents and Settings\ivanovkv\Рабочий стол\NuggerwithoutIE.au3"): If FileExists ($FullPathFile) Then FileMove( $Path & "\" $file, $Path & "\" & $time & " - Logfile.txt") If FileExists ($FullPathFile) Then FileMove( ^ ERROR Error: Error in expression.Because there is an error If FileExists ($FullPathFile) Then FileMove( $Path & "\" $file, $Path & "\" & $time & " - Logfile.txt") Should be If FileExists ($FullPathFile) Then FileMove( $Path & "\" & $file, $Path & "\" & $time & " - Logfile.txt") Of course an easier way to do this would be $time = @MON & "_" & @MDAY & "_" & @hour & "_" & @MIN $Path = "C:\Documents and Settings\blabla\blabla\Logs\" $file = "Logfile.txt" $FullPathFile = $Path & $File $sFile = $Path & $Time & " - " & $File If FileExists ($FullPathFile) Then FileMove($FullPathFile, $sFile) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
2dkot Posted November 18, 2008 Author Posted November 18, 2008 Because there is an error If FileExists ($FullPathFile) Then FileMove( $Path & "\" $file, $Path & "\" & $time & " - Logfile.txt") Should be If FileExists ($FullPathFile) Then FileMove( $Path & "\" & $file, $Path & "\" & $time & " - Logfile.txt") Of course an easier way to do this would be $time = @MON & "_" & @MDAY & "_" & @hour & "_" & @MIN $Path = "C:\Documents and Settings\blabla\blabla\Logs\" $file = "Logfile.txt" $FullPathFile = $Path & $File $sFile = $Path & $Time & " - " & $File If FileExists ($FullPathFile) Then FileMove($FullPathFile, $sFile) Thanks a lot!!! Really appreciate your advises!
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