Merchants Posted June 28, 2011 Share Posted June 28, 2011 (edited) if i put the script file in the same directory as the file that i wana edit it works but if i select folder it does not work Why? expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #NoTrayIcon Global $GUI[10], $Last_Folder = -1 $GUI[0] = GUICreate("Replace File name", 300, 150, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) GUICtrlCreateLabel("Folder", 5, 8) GUICtrlCreateLabel("Find", 5, 38) GUICtrlCreateLabel("Replace", 5, 68) GUICtrlCreateLabel("Type file", 5, 98) GUICtrlCreateLabel("01. (Ex file: 01. test)", 180, 38) GUICtrlSetColor(-1, 0x009933) GUICtrlSetFont(-1, -1, -1, 2) GUICtrlCreateLabel("1 (Ex file after: 1 test)", 180, 68) GUICtrlSetColor(-1, 0x009933) GUICtrlSetFont(-1, -1, -1, 2) GUICtrlCreateLabel("mp3 (Ex file: *.mp3)", 180, 90) GUICtrlSetColor(-1, 0x009933) GUICtrlSetFont(-1, -1, -1, 2) GUICtrlCreateLabel("Default = mp3", 180, 105) GUICtrlSetColor(-1, 0x009933) GUICtrlSetFont(-1, -1, -1, 2) $GUI[1] = GuiCtrlCreateInput("", 50, 5, 125, 20) $GUI[2] = GuiCtrlCreateInput("", 50, 35, 125, 20) $GUI[3] = GuiCtrlCreateInput("", 50, 65, 125, 20) $GUI[4] = GuiCtrlCreateInput("", 50, 95, 125, 20) $GUI[5] = GUICtrlCreateButton("Replace", 50, 122, 90, 22, 0x0001) $GUI[6] = GUICtrlCreateButton("Close", 150, 122, 90, 22) $GUI[7] = GUICtrlCreateButton("Select folder", 180, 4, 100, 22) GUISetState() While 1 $GUI[9] = GUIGetMsg($GUI[0]) Select Case $GUI[9] = $GUI_EVENT_CLOSE Exit Case $GUI[9] = $GUI[6] Exit Case $GUI[9] = $GUI[7] $sTmpFile = FileSelectFolder("Select File:", -1, 1, $Last_Folder) If Not $sTmpFile = "" Then $Last_Folder = $sTmpFile GUICtrlSetData($GUI[1], $sTmpFile) EndIf Case $GUI[9] = $GUI[5] If $GUI[2] = "" Then MsgBox(64,"Error","I don't know what to find!") Else If GUICtrlRead($GUI[4]) = "" Then If GUICtrlRead($GUI[1]) = "" Then $search = FileFindFirstFile("*.mp3") Else $search = FileFindFirstFile(GUICtrlRead($GUI[1]) & "\*.mp3") ; <== here is the problem don't know whats wrong... EndIf Else If GUICtrlRead($GUI[1]) = "" Then $search = FileFindFirstFile("*." & GUICtrlRead($GUI[4])) Else $search = FileFindFirstFile(GUICtrlRead($GUI[1]) & "\*." & GUICtrlRead($GUI[4])) ; <== here is the problem don't know whats wrong... EndIf EndIf If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $text = StringReplace($file, GUICtrlRead($GUI[2]), GUICtrlRead($GUI[3])) FileMove($file, $text, 0) WEnd FileClose($search) EndIf EndSelect WEnd Edited June 28, 2011 by Merchants Link to comment Share on other sites More sharing options...
wraithdu Posted June 28, 2011 Share Posted June 28, 2011 This If Not $sTmpFile = "" Then is incorrect. Sounds right in your head, but no. You want If $sTmpFile <> "" Then Link to comment Share on other sites More sharing options...
Merchants Posted June 28, 2011 Author Share Posted June 28, 2011 (edited) that was not the problem the problem is at Case $GUI[9] = $GUI[5] Edited June 28, 2011 by Merchants Link to comment Share on other sites More sharing options...
wraithdu Posted June 28, 2011 Share Posted June 28, 2011 And other things: Line 47: If GUICtrlRead($GUI[2]) = "" You also need to check @error or if your replace strings are valid. If inputs 2 and 3 are blank, then StringReplace fails and returns an empty string. Link to comment Share on other sites More sharing options...
wraithdu Posted June 28, 2011 Share Posted June 28, 2011 Ah. Also fails because FileFindNextFile only returns a file name, not a full path, and does not change your working directory. You'll need to supply FileMove with the full path. All my other comments are still valid though. Link to comment Share on other sites More sharing options...
Merchants Posted June 28, 2011 Author Share Posted June 28, 2011 (edited) hm indeed ty for help is works now Edited June 28, 2011 by Merchants Link to comment Share on other sites More sharing options...
Developers Jos Posted June 28, 2011 Developers Share Posted June 28, 2011 Alt+D is your friend in SciTE in these kind of cases assuming you loaded the full version. 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...
Merchants Posted June 28, 2011 Author Share Posted June 28, 2011 (edited) uhm ok that was file NAMEbut can it also edit Beschrijving: titel, ondertitel, opmerkingen?and Medium: jaar, number, ect... Edited June 28, 2011 by Merchants Link to comment Share on other sites More sharing options...
Merchants Posted June 30, 2011 Author Share Posted June 30, 2011 nvm i already found it 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