fxg4758 0 Posted July 1, 2011 Hi all. Can someone help me in these troubles i have? 1. How i can center a window that have different sizes? 2. How i create a txt file with files names and rename these files? I want to verify if exist already file 4, so next time i click in the button, the program rename the file to 5.wmv and put in the txt file. Example: test1.wmv - 1.wmv test2.emv - 2.wmv test3.wmv - 3.wmv test4.wmv - 4.wmv test1.wmv - 5.wmv test2.emv - 6.wmv test3.wmv - 7.wmv test4.wmv - 8.wmv Thanks for any help! Share this post Link to post Share on other sites
JoHanatCent 13 Posted July 2, 2011 Hi all. Can someone help me in these troubles i have?1. How i can center a window that have different sizes?2. How i create a txt file with files names and rename these files? I want to verify if exist already file 4, so next time i click in the button, the program rename the file to 5.wmv and put in the txt file.Example:test1.wmv - 1.wmvtest2.emv - 2.wmvtest3.wmv - 3.wmvtest4.wmv - 4.wmvtest1.wmv - 5.wmvtest2.emv - 6.wmvtest3.wmv - 7.wmvtest4.wmv - 8.wmvThanks for any help!Maybe you can stert by writing some script with these in.Then post it here when you get stuck?=== 1. ====WinGetHandleWinGetPosWinMove=== 2. ====FileExistsFileFindFirstFileFileFindNextFileFileOpenFileWrite=== Or Just ====_FileListToArray==== Also =====StringRegExpReplace Share this post Link to post Share on other sites
taietel 34 Posted July 2, 2011 At no.1, if you create a form and want to be centered on the screen, put -1 at the left/top value: GUICreate("your form", width, height, [color="#ff0000"][b]-1[/b][/color], [color="#ff0000"][b]-1[/b][/color], style, extendedstyle) Things you should know first...In the beginning there was only ONE! And zero...Progs:Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Share this post Link to post Share on other sites
fxg4758 0 Posted July 3, 2011 Maybe you can stert by writing some script with these in.Then post it here when you get stuck?=== 1. ====WinGetHandleWinGetPosWinMove=== 2. ====FileExistsFileFindFirstFileFileFindNextFileFileOpenFileWrite=== Or Just ====_FileListToArray==== Also =====StringRegExpReplaceThanks guys for your help. I solve the post 1 with your help. Now, there is the code for post 2. I want to every time i call the function, rename file1 to file4, to 1 to ....Example:test1 - 1.wmvtest2 - 2.wmvtest3 - 3.wmvtest4 - 4.wmvtest1 - 5.wmvtest2 - 6.wmvtest3 - 7.wmvtest4 - 8.wmvtest1 - 9.wmvtest2 - 10.wmvtest3 - 11.wmvtest4 - 12.wmvCode: FileChangeDir("c:\100\") $search = FileFindFirstFile("c:\100\" & File & "*.wmv") If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Return 0 EndIf Local $Count=0 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $Count+=1 $Beta = $file + 1 _FileRename_($file, $Beta,0) $files = FileOpen("list.txt", 1) FileWriteLine($files, $Beta) FileClose($files) WEnd Thanks! Share this post Link to post Share on other sites
JoHanatCent 13 Posted July 3, 2011 (edited) Thanks guys for your help. I solve the post 1 with your help. Now, there is the code for post 2. I want to every time i call the function, rename file1 to file4, to 1 to .... Example: test1 - 1.wmv test2 - 2.wmv test3 - 3.wmv test4 - 4.wmv test1 - 5.wmv test2 - 6.wmv test3 - 7.wmv test4 - 8.wmv test1 - 9.wmv test2 - 10.wmv test3 - 11.wmv test4 - 12.wmv Code: FileChangeDir("c:\100\") $search = FileFindFirstFile("c:\100\" & File & "*.wmv") If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Return 0 EndIf Local $Count=0 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $Count+=1 $Beta = $file + 1 _FileRename_($file, $Beta,0) $files = FileOpen("list.txt", 1) FileWriteLine($files, $Beta) FileClose($files) WEnd Thanks! Progress!! A note: Please try and put your code between: [ autoit]"Here"[ /autoit] (No spaces in between the square brackets!) See some notes inside: FileChangeDir("c:\100\") $File1 = "test*"; Your file prefix $search = FileFindFirstFile($File1 & ".wmv");Extension needed If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Exit 0 EndIf Local $Count = 0 $files = FileOpen("list.txt", 10);<<< Only need to open file once ;For futher detail see the help 10 = 2 and 8 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop; $Count += 1 _FileRename_();Call this function WEnd Func _FileRename_() $Split = StringSplit($file, ".");Creates an Array see Help $2File = $Split[1] & " - " & $Count & "." & $Split[2]; Your new file layout $Result = FileMove($file, $2File); The actual rename FileWriteLine($files, $2File) If $Result = 0 Then MsgBox(262160, "Problem!!", "File could not be renamed!") EndIf EndFunc ;==>_FileRename_ FileClose($files) ShellExecute("list.txt") Added some notes === > Edited July 3, 2011 by JoHanatCent Share this post Link to post Share on other sites
fxg4758 0 Posted July 4, 2011 Progress!! A note: Please try and put your code between: [ autoit]"Here"[ /autoit] (No spaces in between the square brackets!) See some notes inside: FileChangeDir("c:\100\") $File1 = "test*"; Your file prefix $search = FileFindFirstFile($File1 & ".wmv");Extension needed If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Exit 0 EndIf Local $Count = 0 $files = FileOpen("list.txt", 10);<<< Only need to open file once ;For futher detail see the help 10 = 2 and 8 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop; $Count += 1 _FileRename_();Call this function WEnd Func _FileRename_() $Split = StringSplit($file, ".");Creates an Array see Help $2File = $Split[1] & " - " & $Count & "." & $Split[2]; Your new file layout $Result = FileMove($file, $2File); The actual rename FileWriteLine($files, $2File) If $Result = 0 Then MsgBox(262160, "Problem!!", "File could not be renamed!") EndIf EndFunc ;==>_FileRename_ FileClose($files) ShellExecute("list.txt") Added some notes === > Thanks JoHanatCent for your help, but the code is give me error or i explain bad want i need. This your list.txt: test_1 - 1 - 1.wmv test_1 - 2.wmv test_2 - 2 - 3.wmv test_2 - 4.wmv test_3 - 3 - 5.wmv test_4 - 4 - 6.wmv I need this text in order on list.txt: test_1-1.wmv test_2-2.wmv test_3-4.wmv test_4-4.wmv test_1-5.wmv test_2-6.wmv test_3-7.wmv test_4-8.wmv test_1-9.wmv test_2-10.wmv test_3-11.wmv test_4-12.wmv If i make a error on put the information in this post, please tell me. I understand to use the brackets when i put code, but this is only text. Regards! Share this post Link to post Share on other sites
fxg4758 0 Posted July 4, 2011 Hi JoHanatCent. I made a few changes in your code and i get want what is need for my program. Thanks a lot for your help! FileChangeDir("c:\100\") $File1 = MyFile & "*"; Your file prefix $File2 = MyFile & ".txt" $search = FileFindFirstFile($File1 & ".wmv");Extension needed If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Exit 0 EndIf If FileExists("c:\100\" & $File2) Then $File3 = FileReadLine($File2, -1) $File4 = StringTrimLeft($File3,13) & StringTrimRight($File3,4) Local $Count = $File4 Else Local $Count = 0 EndIf $files = FileOpen($File2, 9);<<< Only need to open file once ;For futher detail see the help 10 = 2 and 8 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop; $Count += 1 $Split = StringSplit($file, ".");Creates an Array see Help $2File = $Split[1] & " - " & $Count & "." & "asf"; Your new file layout $Result = FileMove($file, $2File); The actual rename FileWriteLine($files, $2File) If $Result = 0 Then MsgBox(262160, "Problem!!", "File could not be renamed!") EndIf WEnd FileClose($files) ShellExecute($File2) Progress!! A note: Please try and put your code between: [ autoit]"Here"[ /autoit] (No spaces in between the square brackets!) See some notes inside: FileChangeDir("c:\100\") $File1 = "test*"; Your file prefix $search = FileFindFirstFile($File1 & ".wmv");Extension needed If $search = -1 Then MsgBox(262160, "Error!!", "File not found!") Exit 0 EndIf Local $Count = 0 $files = FileOpen("list.txt", 10);<<< Only need to open file once ;For futher detail see the help 10 = 2 and 8 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop; $Count += 1 _FileRename_();Call this function WEnd Func _FileRename_() $Split = StringSplit($file, ".");Creates an Array see Help $2File = $Split[1] & " - " & $Count & "." & $Split[2]; Your new file layout $Result = FileMove($file, $2File); The actual rename FileWriteLine($files, $2File) If $Result = 0 Then MsgBox(262160, "Problem!!", "File could not be renamed!") EndIf EndFunc ;==>_FileRename_ FileClose($files) ShellExecute("list.txt") Added some notes === > Share this post Link to post Share on other sites
JoHanatCent 13 Posted July 4, 2011 Hi JoHanatCent. I made a few changes in your code and i get want what is need for my program. Thanks a lot for your help!Glad I could help. Share this post Link to post Share on other sites