Nahuel Posted September 1, 2007 Share Posted September 1, 2007 (edited) A guy who likes to have his pictures organized asked me for something to rename all the files in a folder (since he doesn't like names like "DCIM8796.JPG"). So I made this for him. Maybe someone can also find it useful. Use at your own risk. expandcollapse popup#include <File.au3> #include <Constants.au3> #include <Guiconstants.au3> #Include <GuiListView.au3> #NoTrayIcon Opt("GUIOnEventMode",1) While 1 $Directorio=FileSelectFolder("",@HomePath) If @error=1 Then MsgBox(0,"Error","No folder selected.") Exit EndIf $lista1=_FileListToArray($Directorio,"*.*",1) If $lista1="" OR $Directorio=@WindowsDir OR $Directorio=@ProgramFilesDir Then MsgBox(48,"Error","The selected folder is either empty or not valid.") Else ExitLoop EndIf WEnd $alto=(25 * $lista1[0]+30) If $alto > @DesktopHeight Then $altoventana=300 $altolista=250 Else $altolista=$alto $altoventana=$alto+50 EndIf GUICreate("Archivos",250,$altoventana) GUISetOnEvent($GUI_EVENT_CLOSE,"_exit") $ListaArchivos=GUICtrlCreateListView("Files in "&$Directorio,10,10,230,$altolista,$LVS_NOSORTHEADER,$LVS_EX_CHECKBOXES) $renombrar=GUICtrlCreateButton("Rename Selected Files",10,$altoventana-30,230) GUICtrlSetOnEvent(-1,"cambiar_nombre") GUISetState() obtenerArchivos() Func obtenerArchivos() $iCheckboxPos = 15 Global $aCheckbox[UBound($lista1)] For $i = 1 To $lista1[0] Step 1 $aCheckbox[$i] = GUICtrlCreateListViewItem($lista1[$i],$ListaArchivos) GUICtrlSetState(-1, $GUI_CHECKED) $aCheckbox[0] = UBound($aCheckbox) Next EndFunc Func _exit() Exit EndFunc Func cambiar_nombre() $nuevonombre=InputBox("Rename Files","Please type the new name for the selected files. A number will be added at the end of each filename.") If $nuevonombre<>"" Then Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(52,"Warning!","You are about to rename ALL the selected files." & @CRLF & "Continue?") Select Case $iMsgBoxAnswer = 6 ;Yes $N=1 For $i = 1 To (UBound($aCheckbox)-1) $sActiveCheckbox = $aCheckbox[$i] If _GUICtrlListViewGetCheckedState($ListaArchivos,$i-1) Then $ArchivoArenombrar=GUICtrlRead($aCheckbox[$i]) $EXTENSION=StringRight($ArchivoArenombrar,4) $largo=StringLen($ArchivoArenombrar) $NOMBRE=(StringLeft($ArchivoArenombrar,$largo-4)) $MoverError=FileMove($Directorio&"\"&$ArchivoArenombrar,$Directorio&"\"&$nuevonombre&"("&$N&")"&$EXTENSION) If $MoverError=0 Then MsgBox(48,"Error","Could not rename: " &$ArchivoArenombrar& @CRLF & "The file is read-only, you don't have permission or the new name matches the old one.") EndIf $N=$N+1 EndIf Next MsgBox(64,"Files Renamed","Finished!") Exit Case $iMsgBoxAnswer = 7 ;No EndSelect EndIf EndFunc;==>cambiar_nombre() While 1 Sleep(100) WEnd Edited September 1, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Achilles Posted September 1, 2007 Share Posted September 1, 2007 I made something like for my GIMP brushes... I was sick of having all these people's weird names for the brush file names... I didn't think of using this for pictures though.. Good idea! My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
therks Posted September 1, 2007 Share Posted September 1, 2007 Is your friend not running Windows XP? Cus with XP if you just select all the files, then hit F2, it will rename them all in a very similar fashion. Cool script though, well done. I like the use of the listview to select which files to rename. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Nahuel Posted September 1, 2007 Author Share Posted September 1, 2007 WinXP HAS THAT!? And thanks guys, it took me quite a while to figure out how to know which ones are checked, hehe. Link to comment Share on other sites More sharing options...
slayerz Posted September 10, 2007 Share Posted September 10, 2007 thanks nahuel...greatz example AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
SmLex 2006 Posted September 21, 2007 Share Posted September 21, 2007 [autoit]; language: Romana/Engleza ; platform: 98/Me/win2k/xp ; author: Neagu Ionut (aka SmLex) ; email: smlex2006@yahoo.com ; Date: 5 Ianuarie 2007 #Region Compiler directives section #Compiler_Prompt = n ;y=show compile menu ;** AUT2EXE setting ;#Compiler_AUT2EXE = C:\Program Files\AutoIt3\beta\Aut2exe\aut2exe.exe ;Override the default compiler with this version. #Compiler_Icon = iconita.ico ;filename of the Ico file to use #Compiler_Compression = 4 ;Compression parameter 0-4 0=Low 2=normal 4=High #Compiler_Allow_Decompile = y ;y= allow decompile #Compiler_PassPhrase=19861987 ;Password to use for compilation ;** Target program Resource info #Compiler_Res_Comment = Pentru mai multe informatii despre Redenumeste SL vizitati www.softwaresl.evonet.ro #Compiler_Res_Description = Program de redenumit mai multe fisiere in acelasi timp. #Compiler_Res_Fileversion = 2.0 ;File Version #Compiler_Res_FileVersion_AutoIncrement=n #Compiler_Res_LegalCopyright= Link to comment Share on other sites More sharing options...
randallc Posted September 21, 2007 Share Posted September 21, 2007 (edited) Hi @smLex_2006, Amazing! thanks, Randall Edited September 21, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Nahuel Posted September 22, 2007 Author Share Posted September 22, 2007 ^ what the hell is that? Link to comment Share on other sites More sharing options...
AU3Newbie Posted September 22, 2007 Share Posted September 22, 2007 #include "WinAnimate.au3" === But where's "WinAnimate.au3"? 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