Willow Posted November 9, 2011 Share Posted November 9, 2011 I am attempting to rename an existing folder based on ticket ref# and date/time stamp. Although the code does run, it will not create the c:\tickets\TKT # mm-dd-yy-hh-mm folder. Any help would be appreciated. Do $mkfld = InputBox("Create Ticket Backup Folder", "Enter Ticket Number ONLY", "", " M5", 250, 130) If @error Then Exit Until StringIsdigit($mkfld) If FileExists($mkfld) Then DirMove($mkfld), ($mkfld) & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "-" & @MIN) DirCreate("c:\tickets\TKT # "&$mkfld) If NOT @Error Then If DirCreate( $mkfld ) Then MsgBox(0, "Success", "Ticket Backup Folder REF # " & $mkfld & " was created") EndIf EndIf Link to comment Share on other sites More sharing options...
water Posted November 9, 2011 Share Posted November 9, 2011 Your DirMove statement is wrong. try something like: Do $mkfld = InputBox("Create Ticket Backup Folder", "Enter Ticket Number ONLY", "", " M5", 250, 130) If @error Then Exit Until StringIsDigit($mkfld) If FileExists($mkfld) Then DirMove($mkfld, $mkfld & " " & @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "-" & @MIN) If @error Then MsgBox(0, "Error", "Error creating Ticket Backup Folder REF # " & $mkfld & "! Error returned is: " & @error) Exit EndIf EndIf DirCreate("c:\tickets\TKT # " & $mkfld) If Not @error Then If DirCreate($mkfld) Then MsgBox(0, "Success", "Ticket Backup Folder REF # " & $mkfld & " was created") EndIf EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
kylomas Posted November 9, 2011 Share Posted November 9, 2011 (edited) Willow, $mkfld will be a string of digits. You are then testing for a filename equal to this string, does such a file exist? If the file exists you are assumming that a dir of the same name exists. Is this true? You also need to review the syntax for dirmove... Can you explain in psuedo-logic what you are trying to do with the series of dircreate's? kylomas Edit: Never mind - too late, water got in b4 me Edited November 9, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Willow Posted November 10, 2011 Author Share Posted November 10, 2011 (edited) @Water:Thanks for the assist. I made a few changes to your code. However I am still having a somewhat related problem. The good news is that the code is now creating the correct folder ie: c:ticketsTKT # 22222.Once the script is run a second time, it sees the existing folder and will create a backup folder such as "c:ticketsTKT # 22222 11-09-2011-19-42" folder which is correct.What is strange though, when run either the first or second time, it is also creating a folder named 22222 in the saved scripts folder.For example, save the attached code sample as ticket.au3 in a "c:myscripts" folder.Next run it and it will create both a "C:ticketsTKT # 22222" folder (correct) and a "c:myscripts22222" folder." This is the underlying problem, why is it creating the "c:myscripts22222" folder" every time?Do $mkfld = InputBox("Create Ticket Backup Folder", "Enter Ticket Number", "", " M5", 250, 130) If @error Then Exit Until StringIsDigit($mkfld) If FileExists($mkfld) Then DirMove( "c:ticketsTKT # " & $mkfld, "c:ticketsTKT # " &$mkfld& @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "-" & @MIN) If @error Then MsgBox(0, "Error", "Error creating Ticket Backup Folder TKT # " & $mkfld & "! Error returned is: " & @error) Exit EndIf EndIf DirCreate("c:ticketsTKT # " & $mkfld) If Not @error Then If DirCreate($mkfld) Then MsgBox(0, "Success", "Ticket Backup Folder TKT # " & $mkfld & " was created") EndIf EndIf Edited November 10, 2011 by Willow Link to comment Share on other sites More sharing options...
gononono64 Posted November 10, 2011 Share Posted November 10, 2011 If DirCreate($mkfld) Then MsgBox(0, "Success", "Ticket Backup Folder TKT # " & $mkfld & " was created") EndI The DirCreate creates a new folder even in an if statement... thus its like saying, create a directory, if the directory is created successfully msgbox.... You want to replace that with If Not @error Then If FileExists("c:ticketsTKT # " & $mkfld) Then MsgBox(0, "Success", "Ticket Backup Folder TKT # " & $mkfld & " was created") EndIf EndIf Link to comment Share on other sites More sharing options...
Willow Posted November 10, 2011 Author Share Posted November 10, 2011 The DirCreate creates a new folder even in an if statement... thus its like saying, create a directory, if the directory is created successfully msgbox....Thanks, however that does not fix the problem of the script creating a "c:myscripts22222" folder.From my previous post.For example, save the attached code sample as ticket.au3 in a "c:myscripts" folder.Next run it and it will create both a "C:ticketsTKT # 22222" folder (correct) and a "c:myscripts22222" folder." This is the underlying problem, why is it creating the "c:myscripts22222" folder" every time? Link to comment Share on other sites More sharing options...
gononono64 Posted November 10, 2011 Share Posted November 10, 2011 Do $mkfld = InputBox("Create Ticket Backup Folder", "Enter Ticket Number", "", " M5", 250, 130) If @error Then Exit Until StringIsDigit($mkfld) If FileExists($mkfld) Then DirMove( "c:ticketsTKT # " & $mkfld, "c:ticketsTKT # " &$mkfld& @MON & "-" & @MDAY & "-" & @YEAR & "-" & @HOUR & "-" & @MIN) If @error Then MsgBox(0, "Error", "Error creating Ticket Backup Folder TKT # " & $mkfld & "! Error returned is: " & @error) Exit EndIf EndIf DirCreate("c:ticketsTKT # " & $mkfld) If Not @error Then If FileExists("c:ticketsTKT # " & $mkfld) Then MsgBox(0, "Success", "Ticket Backup Folder TKT # " & $mkfld & " was created") EndIf EndIf This works fine for me 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