Jump to content

Center Window / Create list files


Recommended Posts

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!

Link to comment
Share on other sites

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!

Maybe you can stert by writing some script with these in.

Then post it here when you get stuck?

=== 1. ====

WinGetHandle

WinGetPos

WinMove

=== 2. ====

FileExists

FileFindFirstFile

FileFindNextFile

FileOpen

FileWrite

=== Or Just ====

_FileListToArray

==== Also =====

StringRegExpReplace

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

Maybe you can stert by writing some script with these in.

Then post it here when you get stuck?

=== 1. ====

WinGetHandle

WinGetPos

WinMove

=== 2. ====

FileExists

FileFindFirstFile

FileFindNextFile

FileOpen

FileWrite

=== Or Just ====

_FileListToArray

==== Also =====

StringRegExpReplace

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!

Link to comment
Share on other sites

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 by JoHanatCent
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 === >

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...