Jump to content

Script Error [HELP]


Recommended Posts

Script Error, Renaming file in autoit

I want to rename a file in autoit...

but there is no filerename command i use the filemove command

File Example: A.COM.INFECTED

i want to rename *.infected file to *.COM

File Example: A.COM.INFECTED To A.COM ONLY...

Please help :unsure:

Code:

$file = @Desktopdir & "\A.COM.INFETED"
$rename = @Desktopdir & "\A.COM"
FileMove($file, $rename)

but I am using the listview command

i want to delete the extension *.infected to its original name...

$hList = GUICtrlCreateListView('Virus Files', 0, 0,681, 396)
$Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
Filemove($sFolder & "\" & $Active, @Desktopdir & $active & "\.com");ERROR! If the file will be move it will rename the file ".com" to the desktop and cannot be deleted... :(
;Help
Edited by GianAutoitprogrammer
Link to comment
Share on other sites

Hi,

then you seem to have a faulty value in one of your variables.

I tend to use ConsoleWrite() to show me the contents of the variables to debug.

The second example will anyway move the same file to the same destination:

a.bc = a.bc.

Anyway I suggest you to match the cases of your variables ($Active = $active) to gain a better overview.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

hi GianAutoItProgrammer,

Does this code produce a file on your desktop named "Demo.exe_renamed"?

FileOpen(@DesktopDir & "\Demo1.exe", 2)
FileClose(@DesktopDir & "\Demo1.exe")
FileMove(@DesktopDir & "\Demo1.exe", @DesktopDir & "\Demo.exe_renamed")

If so, then the problem is elsewhere, likely in your variables, like Hannes123 suggested.

-smartee

Link to comment
Share on other sites

i dont get it

When you want to find bug easily use consolewrite

$Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
ConsoleWrite ( "$sFolder : " & $sFolder & @Crlf )
ConsoleWrite ( "$Active : " & $Active & @Crlf )
$_Filemove = Filemove ( $sFolder & "\" & $Active, @DesktopDir & '\' & $active & ".com" )
ConsoleWrite ( "$_Filemove : " & $_Filemove & @Crlf )

and see if all is correct ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I does not display any text to the console rather it does not execute the console...

I talk about my previous post !

$Active = StringTrimRight(GUICtrlRead(GUICtrlRead($hList)), 1)
ConsoleWrite ( "$sFolder : " & $sFolder & @Crlf )
ConsoleWrite ( "$Active : " & $Active & @Crlf )
$_Filemove = Filemove ( $sFolder & "\" & $Active, @DesktopDir & '\' & $active & ".com" )
ConsoleWrite ( "$_Filemove : " & $_Filemove & @Crlf )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I does not display any text to the console rather it does not execute the console...

If you use a compiled program, you should replace the ConsoleWrite() calls with MsgBox (for example).

The console we are talking of (if the script is not compiled) is located on the bottom of the SciTe4AutoIT editor if you press F5 to run the script.

:unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
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...