Jump to content

auto increment file extention


Recommended Posts

  • Developers

$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 post
Share on other sites

or maybe this

#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)

NEWHeader1.png

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...