GianAutoitprogrammer 0 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 Share this post Link to post Share on other sites
hannes08 39 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] Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 Filecopy($sFolder & "\" & $Active, @Desktopdir & "\" & $active & ".") it doesnt work too... Share this post Link to post Share on other sites
hannes08 39 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] Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 i dont get it Share this post Link to post Share on other sites
smartee 14 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 Share this post Link to post Share on other sites
wakillon 403 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 Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 if the code does/doesnt work then Thanks Smartee & Hannes123 for your help Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 wakillon it doesnt work but thanks Share this post Link to post Share on other sites
wakillon 403 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 Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 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
wakillon 403 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 Share this post Link to post Share on other sites
hannes08 39 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] Share this post Link to post Share on other sites
GianAutoitprogrammer 0 Posted April 19, 2011 Im sorry everybody I gave up with this program, Thanks for all of your help everybody Share this post Link to post Share on other sites