shyang 0 Posted October 5, 2007 Hello All. I'm newbie on autoit...Autoit is really something for various automation. Here's the question. How can I put date with filename.txt ? (I just checked help file and this "General Help and Support" but no luck..maybe I couldn't find it..) what I want to do is to make log filename with timestamp in c:\tmp like this, 200710051730.log.txt 200710051730: date and time . log.txt <--- is fixed filename and extension. How can I make this come true ? thank you in advance. Share this post Link to post Share on other sites
SmOke_N 211 Posted October 5, 2007 Try this:MsgBox(0, 0, _FileToDateTime(@UserProfileDir & "\somefilename.log")) Func _FileToDateTime($sFileIn) ;We should use _PathSplit here, but I'm being lazy Local $sPath, $sFName = $sFileIn If StringInStr($sFName, "\") Then Local $nCount = StringInStr($sFName, "\", 0, -1) $sPath = StringLeft($sFName, $nCount) $sFName = StringTrimLeft($sFName, $nCount) EndIf $sFName = @YEAR & @MON & @MDAY & @HOUR & @MIN & "." & $sFName Return $sPath & $sFName EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
weaponx 16 Posted October 5, 2007 (edited) #Include <Date.au3> #Include <Array.au3> $infile = "C:\somefolder\test.log" $array = StringSplit ( $infile, "\") $array[$array[0]] = StringRegExpReplace (_NowCalc (), "[^0-9]", "") & $array[$array[0]] $outfile = _ArrayToString ($array, "\", 1) MsgBox(0,"",$outfile)oÝ÷ ÚÚºÚ"µÍÒ[ÛYH Ñ]K]LÉÝÂÒ[ÛYH Ð^K]LÉÝÂÙÐÞ ][ÝÉ][ÝË[[YÝ[ ][ÝÐÎÌLÜÛÛYYÛÌLÝÝÙÉ][ÝÊJB[È[[YÝ[ ÌÍÚ[[JB ÌÍØ^HHÝ[ÔÜ] ÌÍÚ[[K ][ÝÉÌLÉ][ÝÊB ÌÍØ^VÉÌÍØ^VÌWHHÝ[ÔYÑ^XÙH ÓÝÐØ[È K ][ÝÖ×NWI][ÝË ][ÝÉ][ÝÊH [È ÌÍØ^VÉÌÍØ^VÌWB]Ð^UÔÝ[È ÌÍØ^K ][ÝÉÌLÉ][ÝËJB[[ Edited October 5, 2007 by weaponx Share this post Link to post Share on other sites
SmOke_N 211 Posted October 5, 2007 (edited) #Include <Date.au3> #Include <Array.au3> $infile = "C:\somefolder\test.log" $array = StringSplit ( $infile, "\") $array[$array[0]] = StringRegExpReplace (_NowCalc (), "[^0-9]", "") & $array[$array[0]] $outfile = _ArrayToString ($array, "\", 1) MsgBox(0,"",$outfile)oÝ÷ Ûú®¢×}÷Ý:.r·ôGb´ôw¢²W¬±Êy«¢+ÙÕ¹}¥±Q½ÑQ¥µÈ ÀÌØíÍ¥±%¸¤(%1½°ÀÌØíÍAÑ °ÀÌØíÍ9µôÀÌØíÍ¥±%¸(%1½°ÀÌØí¹ ½Õ¹ÐôMÑÉ¥¹%¹MÑÈ ÀÌØíÍ9µ°ÅÕ½ÐìÀäÈìÅÕ½Ðì°À°´Ä¤(%%ÀÌØí¹ ½Õ¹ÐQ¡¸($$ÀÌØíÍAÑ ôMÑÉ¥¹1Ð ÀÌØíÍ9µ°ÀÌØí¹ ½Õ¹Ð¤($$ÀÌØíÍ9µôMÑÉ¥¹QÉ¥µ1Ð ÀÌØíÍ9µ°ÀÌØí¹ ½Õ¹Ð¤(%¹%(%IÑÕɸÀÌØíÍAÑ µÀìeHµÀì5=8µÀì5dµÀì!=UHµÀì5%8µÀìÅÕ½Ðì¸ÅÕ½ÐìµÀìÀÌØíÍ9µ)¹Õ¹ Edit2: Ooops forgot $sPath in last Edit Edited October 5, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
weaponx 16 Posted October 5, 2007 Nah yours is 9 lines, mine is 7 or 8. There is also the likelihood that those UDF's are already included in the script! Share this post Link to post Share on other sites
shyang 0 Posted October 5, 2007 Thank you very much everybody.. above answers are what I wanted ~~ Share this post Link to post Share on other sites
weaponx 16 Posted October 5, 2007 Is this better Smoke? $infile = "C:\somefolder\new folder\test.log" MsgBox(0,"",StringLeft($infile, StringInStr ($infile, "\", 0 , -1)) & @YEAR & @MON & @MDAY & @HOUR & @MIN & StringTrimLeft ( $infile,StringInStr ($infile, "\", 0 , -1)))oÝ÷ ÚÚºÚ"µÍÌÍÚ[[HH ][ÝÐÎÌLÜÛÛYYÛÌLÛ]ÈÛÌLÝÝÙÉ][ÝÂÙÐÞ ][ÝÉ][ÝËÝ[ÔYÑ^XÙH ÌÍÚ[[K ][ÝÖ×ÌLÉÌL×JÉÌÍÉ][ÝËQPT [ÈSÓ [ÈQVH [ÈÕT [ÈRSH [ÈÝ[Õ[SY ÌÍÚ[[KÝ[Ò[Ý ÌÍÚ[[K ][ÝÉÌLÉ][ÝËLJJJ Share this post Link to post Share on other sites