Hello once more.
After coding my [Anime Renamer] i felt like to do something better and ... not self based
Therefore....
I started the [Smart Renamer]
Basically you set up a template for the stuff you want to rename, for example
Code:
[%Anime%] %Team% #/*
This will create 2 edit box with a text (the one enclosed within %%) upon them.
And then another edit box for the counter ( represented by #)
After the slash comes the extention... to keep the old one just put *
It almost prepares coffee :p
Then you just have to drag drop files upon the window to start renaming them
Please post your comments. (Any of them !!! Flaming is allowed too >_< , well at least if the person has solid arguments)
THE CODE (Commented ^_^)
Code:
#SingleInstance Off
SetBatchLines, -1
;-----------------------File Management------------------------------
IfNotExist, Template
FileAppend, [Templates]`nTemp1=`%Example`% #/*, Template
Loop
{
IniRead, Temp%A_Index%, Template, Templates, Temp%A_Index%
IfEqual, Temp%A_Index%, ERROR, Break
}
;--------------------------------------------------------------------
Str := Temp1 ;Take the first template as default
Err2 = No start number
Menu, FileMenu, Add, &Templates, Templates
Menu, FileMenu, Add, E&xit, Exit
Menu, Menu, Add, &File, :FileMenu
Gui_Create:
Gui, 1:Default
Name =
Gui_Num = 0
Pos = 1
Loop, Parse, Str, /
If (A_Index & 1) ;Separate the string in string/extension
{
Loop, Parse, A_LoopField, `%
If (A_Index & 1)
Name := Name "|" A_LoopField ;Replace the percent enclosed stuff by pipes
Else
{
Gui_Num++ ;How many variables
Pos%A_LoopField% := A_Index ;Remember the variable position
Title%Gui_Num% := A_LoopField ;Remember the variable name
}
}
Else
Ext := A_LoopField ;Store the extension
StringTrimLeft, Name, Name, 1 ;Remove the heading pipe
Width := Gui_Num*100-8 ;Set the control positioning equation
Gui, 1:-SysMenu +AlwaysOnTop
Loop %Gui_Num% ;Create controls
{
Gui, Add, Text, x%Pos% y0 w50 h11, % Title%A_Index%
Gui, Add, Edit, x%Pos% y12 w90 h18 vText%A_Index%
Pos += 100
}
Gui, Menu, Menu
Gui, Add, Text, x1 y31 w50 h11 , Count
Gui, Add, Edit, x1 y50 w90 h18 Number v#
Gui, Show, h90 w%Width%, Smart Renamer
Return
GuiDropFiles:
Gui, Submit, Nohide ;Save the current vars
IfEqual, #,
{ ;The counter variable is empty
Loop, Parse, A_GuiControlEvent, `n ;Parse the file list
{
Line++
If (Line != 1)
{
Error(Err2)
Line = 0
Exit
}
}
Line = 0
}
List := A_GuiControlEvent ;Duplicate the list
Sort List, \ ;Sort the list
NName := Name ;Duplicate the string
Loop %Gui_Num%
{
StringReplace, NName, NName, |, % Text%A_Index% ;Replaces each pipe with the edit vlabel
}
NumLen := StrLen(#)
Zeroes = 0
Loop, Parse, # ;Counter is set with heading zeroes?
{
If !(A_LoopField = "0")
Break
Zeroes++
}
Loop, Parse, List, `n
{
If (Zeroes != 0)
{
Loop %Zeroes%
# = 0%#%
StringRight #, #, NumLen ;Keep as much chars as input (avoid 01 => 2)
}
StringReplace, FileName, NName, #, %#% ;Replace # with the counter
If # =
StringTrimRight, FileName, FileName, 1 ;Delete the tailing space if there is no counter
SplitPath, A_LoopField,, Dir, OExt
IfEqual, Ext, * ;Extension is not specified ?
{
Nxt := OExt
FileMoveDir, %A_LoopField%, %Dir%\%FileName% ;Rename Dir
}
Else
Nxt := Ext
FileMove, %A_LoopField%, %Dir%\%FileName%.%Nxt% ;Rename File
If ErrorLevel <> 0
Msgbox,, ERROR, Could not process file(s).
#++
}
Return
Error(ByRef Error_Text)
{
Gui, Submit
MsgBox,,ERROR, %Error_Text%
Gui, Show
}
Templates: ;Choose among templates
Gui, Destroy
Gui, 2:-SysMenu +AlwaysOnTop
Gui, 2:Default
Gui, 2:Add, ListView, NoSortHdr gChoose, Number|Content
Loop
{
IfEqual, Temp%A_Index%, ERROR, Break
LV_Add("", A_Index, Temp%A_Index%)
}
Gui, 2:Show,, Templates
Return
Choose:
WinGetPos, Cx, Cy,,, A
If A_GuiEvent = DoubleClick ;Double click = choose template
{
LV_GetText(RowNum, A_EventInfo, 1)
LV_GetText(RowContent, A_EventInfo, 2)
Str := Temp%RowNum% ;Set the string to be the choosen one
Gui, 2:Submit
Gosub, Gui_Create ;Recreate the gui with the newly got input
}
return
Exit:
ExitApp
Future Improvements :
-A non-Ridiculous Gui (Almost Done :p)
-Load templates from files ? (Done)
-Maybe a menu to create and choose amongst the templates (Done)
I don't know.... anyway if it isn't that much usefull for other people than me i will not tweak it that much

Edit : Now reading from file and possibility to choose the wanted template.
Edit : 11/06/06 Now everything is working as expected (filels AND folders ) and code is commented
Edit : 03/07/06 Added error recognition / shortened the code ^_^[/code]