GianAutoitprogrammer Posted April 19, 2011 Share Posted April 19, 2011 (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 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 April 19, 2011 by GianAutoitprogrammer Link to comment Share on other sites More sharing options...
hannes08 Posted April 19, 2011 Share Posted April 19, 2011 Hi, maybe you forgot to use a "\" backslash between @DEsktopDir and $Active. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 Filecopy($sFolder & "\" & $Active, @Desktopdir & "\" & $active & ".") it doesnt work too... Link to comment Share on other sites More sharing options...
hannes08 Posted April 19, 2011 Share Posted April 19, 2011 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 More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 i dont get it Link to comment Share on other sites More sharing options...
smartee Posted April 19, 2011 Share Posted April 19, 2011 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 More sharing options...
wakillon Posted April 19, 2011 Share Posted April 19, 2011 (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 ! Edited April 19, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 if the code does/doesnt work then Thanks Smartee & Hannes123 for your help Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 wakillon it doesnt work but thanks Link to comment Share on other sites More sharing options...
wakillon Posted April 19, 2011 Share Posted April 19, 2011 wakillon it doesnt work but thanks Please Show what's return console ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 I does not display any text to the console rather it does not execute the console... Link to comment Share on other sites More sharing options...
wakillon Posted April 19, 2011 Share Posted April 19, 2011 (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 April 19, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
hannes08 Posted April 19, 2011 Share Posted April 19, 2011 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. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 19, 2011 Author Share Posted April 19, 2011 Im sorry everybody I gave up with this program, Thanks for all of your help everybody 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