SMK281 Posted May 30, 2010 Share Posted May 30, 2010 I've been working on a vbscript application to automate the renaming of jpg files in Windows Explorer. Briefly the user can reorder files when using the thumbnails view and then the code will rename them numerically in the displayed order (not the system file order). The code relies heavily on sending key strokes and use of the clipboard to copy file name string. Generally the code does a pretty good job of the task and I have it working on approx 50 computers (really). It's fast and convenient and the users really like it, as formerly they were doing this by hand. The problem I have is that the keystrokes method and receiving items from the clipboard is not as reliable as I would like. I am fairly new to AutoIT, but I have noticed that direct communication with controls is supported. I would like some general advice on how to solve this problem. That is, how can I extract from Windows Explorer the DISPLAYED order of thumbnail items. Please note this is the order of the images a user would set by dragging the thumbnails within the window - not the system file order. Any advice would be appreciated. SMK Link to comment Share on other sites More sharing options...
JohnOne Posted May 30, 2010 Share Posted May 30, 2010 I dont know the answer to this, but from what I have seen around the forum, there has been plenty a script transcoded from VBS to Autoit3, (which is what I read your post as) so perhps posting your VBS code will help. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
SMK281 Posted May 30, 2010 Author Share Posted May 30, 2010 I dont know the answer to this, but from what I have seen around the forum, there has been plenty a script transcoded from VBS to Autoit3, (which is what I read your post as) so perhps posting your VBS code will help.Yep, thanks for this. I don't think posting the code will help as it uses send keystrokes and clipboard methods extensively and this is what I want to get away from. I just want any advice about reading file names in the order they are displayed using direct communication with windows explorers controls. Link to comment Share on other sites More sharing options...
JohnOne Posted May 30, 2010 Share Posted May 30, 2010 This is a bit nasty, but you should see something you can use. Drag a jpg (or whatever file) into it and it will rename it with increasing numbers at beggining of filename (Test.jpg = 1Test.jpg) provided you have the privilages. #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <EditConstants.au3> $Count = 1 ; Set count $sNewPath = "" ; Set new path GUICreate("Rename", 300, 200, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) ;Make a gui, have it accept files $EditDrop = GUICtrlCreateEdit("Drop first file here",0,0,300,200) ;Make an edit control GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;Set control to accept drops GUISetState() ;Show Gui While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;Exit Exit Case $GUI_EVENT_DROPPED ;Deal with dropped file $sFilePath = @GUI_DragFile ; get path to file $aTemp = StringSplit($sFilePath,"\",3) ;Split into array For $i = 0 to UBound($aTemp) -2 $sNewPath &= $aTemp[$i] & "\" ;Create a newpath minus the filename Next $sNewPath &= $Count & $aTemp[UBound($aTemp) -1] ;Add New filename with added count number ConsoleWrite($sFilePath) ; check original path ConsoleWrite($sNewPath & @CRLF) ; Check new path FileMove($sFilePath,$sNewPath,1) ; Renam rename file $Count += 1 ; increase counter $sNewPath = "" ;Reset New Path GUICtrlSetData($EditDrop,"Drop next file here") ; Change text EndSwitch WEnd It wont be exactly what you need but might help you get it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
SMK281 Posted May 31, 2010 Author Share Posted May 31, 2010 This is a bit nasty, but you should see something you can use. Drag a jpg (or whatever file) into it and it will rename it with increasing numbers at beggining of filename (Test.jpg = 1Test.jpg) provided you have the privilages. #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <EditConstants.au3> $Count = 1 ; Set count $sNewPath = "" ; Set new path GUICreate("Rename", 300, 200, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) ;Make a gui, have it accept files $EditDrop = GUICtrlCreateEdit("Drop first file here",0,0,300,200) ;Make an edit control GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;Set control to accept drops GUISetState() ;Show Gui While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;Exit Exit Case $GUI_EVENT_DROPPED ;Deal with dropped file $sFilePath = @GUI_DragFile ; get path to file $aTemp = StringSplit($sFilePath,"\",3) ;Split into array For $i = 0 to UBound($aTemp) -2 $sNewPath &= $aTemp[$i] & "\" ;Create a newpath minus the filename Next $sNewPath &= $Count & $aTemp[UBound($aTemp) -1] ;Add New filename with added count number ConsoleWrite($sFilePath) ; check original path ConsoleWrite($sNewPath & @CRLF) ; Check new path FileMove($sFilePath,$sNewPath,1) ; Renam rename file $Count += 1 ; increase counter $sNewPath = "" ;Reset New Path GUICtrlSetData($EditDrop,"Drop next file here") ; Change text EndSwitch WEnd It wont be exactly what you need but might help you get it. Thanks for this - it has given me a couple of ideas, but my users are used to clicking one button and the code takes care of the rest. 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