sbrady Posted November 6, 2012 Share Posted November 6, 2012 I am coding on an XP machine and everything works. I will be using my scripts on a Win 7 machine, where nothing works. the #3 button on the interface it what I am testing, a file rename script. I think it has to do with how the name of the open window is interpreted. any ideas as to what to do. I CANNOT code on the Win7 machine right now, it will be several months. Here is the pile of code I have written that DOES WORK on this XP machine. the file I use to test button #3 would have this name to start with: AR123 Smith, Bob v1 FULL MIX.txt (before) AR123 Smith, Bob FULL MIX v1.txt (after) expandcollapse popup; GUI create #include #include #include #include Example() Func Example() Local $Button_1, $Button_2, $Button_3, $Button_3, $msg GUICreate("DAW1 Scripts", 220,220) ; will create a dialog box that when displayed is centered ;$textbox_input = GUICtrlCreateInput("AR123 Smith, Bob", 10, 35, 350, 20) ; will not accept drag&drop files ;$new_project_name = GUICtrlRead($textbox_input) Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton(" 1. Promo Prep", 20, 30, 180,30, $BS_LEFT) $Button_2 = GUICtrlCreateButton(" 2. Make NPR Promo folder", -180, 10, 180,30, $BS_LEFT) $Button_3 = GUICtrlCreateButton(" 3. Rename Mixes", -180, 10, 180,30, $BS_LEFT) $Button_4 = GUICtrlCreateButton(" 4. NEXTDAY to DMG", -180, 10, 180,30, $BS_LEFT) GUISetState() ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;BUTTON 1 Promo Prep Case $msg = $Button_1 ;BUTTON 2 Make NPR folder Case $msg = $Button_2 ; month $the_month = @MON ;the day $the_day = @mday ;the year $the_year = @YEAR $the_year2 = StringTrimLeft ($the_year,2) $todays_promo1 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos NPR"; 10-15-12 $todays_promo2 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos" $NPR_PROMO_FOLDER = "D:\Promos\" & $todays_promo1 DirCreate($NPR_PROMO_FOLDER) ; 10-15-12 Promo NPR ClipPut($todays_promo2) ; 10-15-12 Promo ;Button 3 Rename Mixes Case $msg = $Button_3 ;start Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") $aWinList=WinList("[REGEXPCLASS:^(Explore|Cabinet)WClass$]") For $i = 1 To $aWinList[0][0] ; Get base folder and selections $aSelection = _ExplorerWinGetSelectedItems($aWinList[$i][1]) ; Display as strings ConsoleWrite("Explorer Window: " & $aSelection[1] & " Selection(s)" & @CRLF) For $j = 2 To $aSelection[0] + 1 ConsoleWrite(@TAB & $aSelection[$j] & @CRLF) Next ; START SHAWN's CODE____________________________ ; repeat with the selected items For $File_Name = 1 To $aSelection ; check if file name contains "Full MIX" or "SOT MIX" or "M&E MIX" $result = StringInStr($File_Name, "mix",0,1) If $result > 0 Then $filename2 = StringInStr ( $File_Name, "\" , 0 , -1) ;1st occurance from of "\" from right (47 chars in) $the_folder_path = StringLeft ( $File_Name, $filename2 ) ; C:\Documents and Settings\sebrad\Desktop\shawn\ $file_path_len = StringLen($File_Name) ; 79 characters $char_in_file_name = $file_path_len - $filename2 ;31 $orig_file_name = StringRight ($File_Name, $char_in_file_name) ;AR123 Smith, Bob v1 FULL MIX.txt $new_file_name = StringRegExpReplace($orig_file_name, "(?i)(.*)(\sv.*)(\s.*\sMIX)(\.txt)", "$1$3$2$4") ;AR123 Smith, Bob FULL MIX v1.txt ;MsgBox(4096, "THE result", $new_file_name) FileCopy ( $File_Name, ($the_folder_path & $new_file_name), 1 ) ; with overwright FileDelete ( $the_folder_path & $orig_file_name) EndIf Next ; END SHAWN's CODE________________________ Next ;end ; BUTTON 4 copy NEXTDAY to DMG PROMOS Case $msg = $Button_4 ; month $the_month = @MON ;the day $the_day = @mday ;the year $the_year = @YEAR $the_year2 = StringTrimLeft ($the_year,2) ; set the name for DMG (Digital Media Group) $todays_promo = "NEXTDAY " & $the_month & "-" & $the_day & "-" & $the_year2 ;NEXTDAY 10-15-12 ShellExecute("\\10.100.20.40\DMG Drop Off\Streaming\PROMOS") ; open DMG folder WinWait("PROMOS") ; wait till the drive exists WinMove("PROMOS","",50,800,200,300) ; open the drive in lower left of the screen $NDP_SRC = "D:\Promos\NEXTDAY.mxf" $DEST = "\\10.100.20.40\DMG Drop Off\Streaming\PROMOS\" & $todays_promo FileCopy ($NDP_SRC,$DEST) ;move NEXTDAY and rename to DMG EndSelect WEnd EndFunc ;==>Example ; ========================================================================================================================== ; Func _ObjectSHFolderViewFromWin($hWnd) ; ; Returns an 'ShellFolderView' Object for the given Window handle ; ; Author: Ascend4nt, based on code by KaFu, klaus.s ; ========================================================================================================================== Func _ObjectSHFolderViewFromWin($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1,0,0) Local $oShell,$oShellWindows,$oIEObject,$oSHFolderView ; Shell Object $oShell=ObjCreate("Shell.Application") If Not IsObj($oShell) Then Return SetError(2,0,0) ; Get a 'ShellWindows Collection' object $oShellWindows = $oShell.Windows() If Not IsObj($oShellWindows) Then Return SetError(3,0,0) ; Iterate through the collection - each of type 'InternetExplorer' Object For $oIEObject In $oShellWindows If $oIEObject.HWND = $hWnd Then ; InternetExplorer->Document = ShellFolderView object $oSHFolderView=$oIEObject.Document If IsObj($oSHFolderView) Then Return $oSHFolderView Return SetError(4,0,0) EndIf Next Return SetError(-1,0,0) EndFunc ; ========================================================================================================================== ; Func _ExplorerWinGetSelectedItems($hWnd) ; ; ; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification) ; ========================================================================================================================== Func _ExplorerWinGetSelectedItems($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1,0,'') Local $oSHFolderView Local $iSelectedItems,$iCounter=2,$aSelectedItems[2] = [0, ""] $oSHFolderView=_ObjectSHFolderViewFromWin($hWnd) If @error Then Return SetError(@error,0,'') ; SelectedItems = FolderItems Collection object->Count $iSelectedItems = $oSHFolderView.SelectedItems.Count Dim $aSelectedItems[$iSelectedItems+2] ; 2 extra -> 1 for count [0], 1 for Folder Path [1] $aSelectedItems[0]=$iSelectedItems ; ShellFolderView->Folder->Self as 'FolderItem'->Path $aSelectedItems[1]=$oSHFolderView.Folder.Self.Path ; ShellFolderView->SelectedItems = FolderItems Collection object $oSelectedFolderItems = $oSHFolderView.SelectedItems #cs ; For ALL items in an Explorer window (not just the selected ones): $oSelectedFolderItems = $oSHFolderView.Folder.Items ReDim $aSelectedItems[$oSelectedFolderItems.Count+2] #ce For $oFolderItem In $oSelectedFolderItems $aSelectedItems[$iCounter] = $oFolderItem.Path $iCounter += 1 Next Return SetExtended($iCounter-2,$aSelectedItems) EndFunc ;==>_ExplorerWinGetSelectedItems Func _ComErrFunc($oError) ConsoleWrite("COM Error occurred:" & @CRLF & _ "Number: " & @TAB & $oError.number & @CRLF & _ "Windescription:" & @TAB & $oError.windescription & @CRLF & _ "Description is: " & @TAB & $oError.description & @CRLF & _ "Source is: " & @TAB & $oError.source & @CRLF & _ "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ComErrFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady,Where does the code fail? At the moment you have no errorchecking at all so any one of the lines in the $Button_3 code could be the problem. Go and put some error checks into the code and see if you can narrow it down a bit so that we have something to work on. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 (edited) OK thanks I'll try. when I ran this on a win7 machine, it deleted the selected files, it just didnt make a copy in the same location with the new name. StringRegExpReplace is not functioning...........hmmmm Edited November 6, 2012 by sbrady Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady,Then I suggest you check the parameters to the FileCopy function to see if you have them set correctly. You might also check if you have write permission for that folder. Incidentally, do you realise that you can use FileMove to rename files? Then you do not have to do the double Copy/Delete thing. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2012 Share Posted November 6, 2012 Not to shave too fine a point here, but the code that I pointed out earlier in this script is still written incorrectly This will never work on XP or Windows 7. $File_Name is going to equal a number, it will never equal a file name in this loop. $aSelection is an array, so looping to an array is not going to work, you probably want $aSelection[0] here, although I don't know the contents of $aSelection so I'm not sure. For $File_Name = 1 To $aSelection ; check if file name contains "Full MIX" or "SOT MIX" or "M&E MIX" $result = StringInStr($File_Name, "mix", 0, 1) If $result > 0 Then $filename2 = StringInStr($File_Name, "", 0, -1) ;1st occurance from of "" from right (47 chars in) $the_folder_path = StringLeft($File_Name, $filename2) ; C:Documents and SettingssebradDesktopshawn $file_path_len = StringLen($File_Name) ; 79 characters $char_in_file_name = $file_path_len - $filename2 ;31 $orig_file_name = StringRight($File_Name, $char_in_file_name) ;AR123 Smith, Bob v1 FULL MIX.txt $new_file_name = StringRegExpReplace($orig_file_name, "(?i)(.*)(sv.*)(s.*sMIX)(.txt)", "$1$3$2$4") ;AR123 Smith, Bob FULL MIX v1.txt ;MsgBox(4096, "THE result", $new_file_name) FileCopy($File_Name, ($the_folder_path & $new_file_name), 1) ; with overwright FileDelete($the_folder_path & $orig_file_name) EndIf Next If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 thanks for the tip I'll try it, but it does work on my machine, I can prove it. I'll gladly take any help. I will trying using the FileMove instead of copy 1st though. Thanks. the contents of $aSelection are: C;folderfolderfolderAR123 Smith, Bob v1 FULL MIX.txt C;folderfolderfolderAR123 Smith, Bob v1 SOT MIX.txt C;folderfolderfolderAR123 Smith, Bob v1 M&E MIX.txt Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2012 Share Posted November 6, 2012 I'll be damned if you're not right. I ran this code on my computer and monitored the contents of $File_Name while it ran through that loop and this is what I get.Explorer Window: C:Program Files7-Zip Selection(s) C:Program Files7-ZipHistory.txt C:Program Files7-ZipLicense.txt C:Program Files7-Zipreadme.txt@@ Debug(161) : $File_Name = 1>Error code: 0@@ Debug(161) : $File_Name = C:Program Files7-Zip>Error code: 0@@ Debug(161) : $File_Name = C:Program Files7-ZipHistory.txt>Error code: 0@@ Debug(161) : $File_Name = C:Program Files7-ZipLicense.txt>Error code: 0@@ Debug(161) : $File_Name = C:Program Files7-Zipreadme.txt>Error code: 0From everything I've read and done with For loops before, this should NOT be happening the way it is. There appears to be a bug in the code for For/Next in that it's acting like it's a For/In/Next loop instead. I apologize for not testing this before I said the previous. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 I put a msg after each of my lines of code, on the win7 machine, the file DOES NOT get renamed so nothing really happens, no new file is created with the new name. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady,So the FileCopy fails. Now we have something to work on. Are the parameters correct - are you using the correct current path and new path? Do you have write permission for that folder (although as you can apparently delete you probably do)? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 its the StringRegExpReplace that is not working. The same name is returned somewhere along the way so I guess file copy is working, but its really just a straight replace. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady,See now how errorchecking helps? Next step - what exactly do you have as $orig_file_name? You say that the SRE I gave you works on XP - so there must be something different with the starting value on the Win7 box. What do you pass to the SRE that fails? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 on XP the message box gives me the original name ie "v1 FULL MIX" and the renamed version ie "FULL MIX v1" on W7, both names are the same, so the SRE gets the original name, it just does not convert the original name. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady, I not believe that the SRE engine in AutoIt is OS-sensitive. So there must be something else going wrong. Are you sure that there is absolutely no difference between the file names you feed into the SRE from the XP and Win7 boxes? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 I only have 1 script created. I save it as an exe. Only difference is one runs as an app on Win7, the other, a script running on XP. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2012 Share Posted November 6, 2012 When I ran the code above, substituting a pre-built array for the files selected from the Windows Explorer window, I get the correct results in the output. Here's the modified code, with consolewrites for each variable along the way. expandcollapse popup;start Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") $aWinList = WinList("[REGEXPCLASS:^(Explore|Cabinet)WClass$]") ;~ For $i = 1 To $aWinList[0][0] ; Get base folder and selections ;~ $aSelection = _ExplorerWinGetSelectedItems($aWinList[$i][1]) Global $aSelection[3] = ["C:folderfolderfolderAR123 Smith, Bob v1 FULL MIX.txt", "C:folderfolderfolderAR123 Smith, Bob v1 SOT MIX.txt", "C:folderfolderfolderAR123 Smith, Bob v1 M&E MIX.txt"] ; Display as strings ConsoleWrite("Explorer Window: " & $aSelection[1] & " Selection(s)" & @CRLF) For $j = 2 To $aSelection[0] + 1 ConsoleWrite(@TAB & $aSelection[$j] & @CRLF) Next ; START SHAWN's CODE____________________________ ; repeat with the selected items For $File_Name = 1 To $aSelection ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $File_Name = ' & $File_Name & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ; check if file name contains "Full MIX" or "SOT MIX" or "M&E MIX" $result = StringInStr($File_Name, "mix", 0, 1) If $result > 0 Then $filename2 = StringInStr($File_Name, "", 0, -1) ;1st occurance from of "" from right (47 chars in) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $filename2 = ' & $filename2 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $the_folder_path = StringLeft($File_Name, $filename2) ; C:Documents and SettingssebradDesktopshawn ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $the_folder_path = ' & $the_folder_path & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $file_path_len = StringLen($File_Name) ; 79 characters ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $file_path_len = ' & $file_path_len & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $char_in_file_name = $file_path_len - $filename2 ;31 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $char_in_file_name = ' & $char_in_file_name & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $orig_file_name = StringRight($File_Name, $char_in_file_name) ;AR123 Smith, Bob v1 FULL MIX.txt ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $orig_file_name = ' & $orig_file_name & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $new_file_name = StringRegExpReplace($orig_file_name, "(?i)(.*)(sv.*)(s.*sMIX)(.txt)", "$1$3$2$4") ;AR123 Smith, Bob FULL MIX v1.txt ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $new_file_name = ' & $new_file_name & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;MsgBox(4096, "THE result", $new_file_name) ;~ FileCopy($File_Name, ($the_folder_path & $new_file_name), 1) ; with overwright ;~ FileDelete($the_folder_path & $orig_file_name) EndIf Next ; END SHAWN's CODE________________________ ;~ Next ;end This is the code from the $button_3 section of the While loop. here is the output I get. Explorer Window: C:folderfolderfolderAR123 Smith, Bob v1 SOT MIX.txt Selection(s) @@ Debug(161) : $File_Name = 1 >Error code: 0 @@ Debug(161) : $File_Name = C:folderfolderfolderAR123 Smith, Bob v1 SOT MIX.txt >Error code: 0 @@ Debug(166) : $filename2 = 24 >Error code: 0 @@ Debug(168) : $the_folder_path = C:folderfolderfolder >Error code: 0 @@ Debug(170) : $file_path_len = 55 >Error code: 0 @@ Debug(172) : $char_in_file_name = 31 >Error code: 0 @@ Debug(174) : $orig_file_name = AR123 Smith, Bob v1 SOT MIX.txt >Error code: 0 @@ Debug(176) : $new_file_name = AR123 Smith, Bob SOT MIX v1.txt >Error code: 0 @@ Debug(161) : $File_Name = C:folderfolderfolderAR123 Smith, Bob v1 M&E MIX.txt >Error code: 0 @@ Debug(166) : $filename2 = 24 >Error code: 0 @@ Debug(168) : $the_folder_path = C:folderfolderfolder >Error code: 0 @@ Debug(170) : $file_path_len = 55 >Error code: 0 @@ Debug(172) : $char_in_file_name = 31 >Error code: 0 @@ Debug(174) : $orig_file_name = AR123 Smith, Bob v1 M&E MIX.txt >Error code: 0 @@ Debug(176) : $new_file_name = AR123 Smith, Bob M&E MIX v1.txt >Error code: 0 +>14:36:06 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 5.063 As you can see, the first file name is missing due to the way you have your For loop set up, but all the others are working as expected. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2012 Moderators Share Posted November 6, 2012 sbrady,I did not ask if the scripts were different - I asked if the values passed to the SRE are different. Certain folders are named differently in different OSes (particularly if you have an x32/x64 mismatch) and that might be the cause of the problem. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 holy cow Batman, OK, I guess I'll copy and paste your code and see what results I get. Thanks so much for all your help. Link to comment Share on other sites More sharing options...
sbrady Posted November 6, 2012 Author Share Posted November 6, 2012 as far as I know.......I believe data that gets passed IS the same but I'll see if I can put an error check in place. 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