Sign in to follow this  
Followers 0
GianAutoitprogrammer

Script Error [HELP]

14 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Hi,

maybe you forgot to use a "\" backslash between @DEsktopDir and $Active.

:unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Filecopy($sFolder & "\" & $Active, @Desktopdir & "\" & $active & ".")

it doesnt work too... :unsure:

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

i dont get it

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

if the code does/doesnt work then Thanks Smartee & Hannes123 for your help :unsure:

Share this post


Link to post
Share on other sites

wakillon it doesnt work but thanks :unsure:

Share this post


Link to post
Share on other sites

wakillon it doesnt work but thanks :unsure:

Please Show what's return console ! Posted Image


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Im sorry everybody I gave up with this program, Thanks for all of your help everybody :unsure:

Share this post


Link to post
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
Sign in to follow this  
Followers 0