Zithen Posted October 28, 2005 Share Posted October 28, 2005 making a script that will be a file when ran, but i dont want it to overwite the existing file if it finds it. would like to have it name .000 then increment if it already exists too. how can i go about doing this? Link to comment Share on other sites More sharing options...
w0uter Posted October 28, 2005 Share Posted October 28, 2005 use something like $variable = 0 while 1 if fileexists( "string" & $variable) then $variable += 1 $name = "string" & $variable wend My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Zithen Posted October 28, 2005 Author Share Posted October 28, 2005 heh...looking at that and thinking about it, i feel dumb...its so easy its gotta workuse something like$variable = 0while 1if fileexists( "string" & $variable) then $variable += 1$name = "string" & $variablewend Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2005 Developers Share Posted October 28, 2005 $variable = 0 while fileexists( "Filename." & StringFormat("%03i",$variable)) $variable = $variable + 1 wend $Filename = "Filename." & StringFormat("%03i",$variable) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted October 28, 2005 Share Posted October 28, 2005 or maybe this expandcollapse popup#include <GUIConstants.au3> Dim $location ; opens a new file every time script is ran ; or New File button is pressed New_file() GUICreate("GUICtrlCreateDummy",450,100, 100,200) $user = GUICtrlCreateDummy() $button = GUICtrlCreateButton ("New File",40,70,70,20) $cancel = GUICtrlCreateButton ("Cancel",150,70,70,20) $notice = GUICtrlCreateLabel($location, 20, 20, 400, 20, $SS_SUNKEN) GUISetState() Do $msg = GUIGetMsg () Select Case $msg = $button New_file() MsgBox(0,"new file name", $location & " " ) GUICtrlSetData($notice, $location) Case $msg = $cancel exit Case $msg = $user ; special action before closing ; ... exit EndSelect Until $msg = $GUI_EVENT_CLOSE ;--------------------------- Start - Functions ------------------------------------------ Func New_file() For $x = 1 to 1000 If Not FileExists(@ScriptDir & "\test"& $x & ".txt" ) Then FileWrite(@ScriptDir & "\test"& $x & ".txt", "File Started " & @MDAY & "-" & @MON & "-" & @YEAR ) $location = @ScriptDir & "\test"& $x & ".txt" ExitLoop EndIf Next EndFunc 8) 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