#singleinstance force
#NoTrayIcon
SetBatchLines,-1
#NoEnv
#Persistent
SetWorkingDir %A_ScriptDir%
SplashImage,, W258 B2 ,,Renaming...
;_________________________________________________________________________________________________
Clipboard := ""
fileAppend ,
(
`n;NothingToAdd=
), Renamer.ahk
fileAppend ,
(
`n;%clipboard%=
), Renamer.ahk
;_________________________________________________________________________________________________
Strip( _String )
{
_String = %_String%
}
/*
indexer( _String, address )
{
loop, %address%\*,1,0
{
if( _String
== A_LoopFileName
)
{
Loop, %address%\*,1
{
If InStr
(LoopFileName
, %_String%
. "(1)")
}
}
}
}
*/
listReplace( _String )
{
start := 0
loop read, %A_WorkingDir%\Renamer.ahk
{
{
if ( A_LoopReadLine
= ";!start" )
{
start := 1
}
{
continue
}
}
{
}
{
; get rid of repeated spaces
_String := RegExReplace(_String," +"," ")
; trim whitespace
_String = %_String%
}
}
}
;_string is the file or foldername that needs to be renamed.
;_flag is to tell the function to work with an extension or not.
;_flag = 1 will return with extension( for files ).
;_flag != 1 will return without extension( for folders ).
Replace( _String, _flag )
{
;split the extension and filename and put them in seperate strings.
{
splitpath _String,,,_Extension, _String
}
;---------------------------------------------------------------------- Replace the following with spaces
_String := RegExReplace(_String,"\.|_|-"," ")
;---------------------------------------------------------------------- Replace the following with blanks
_String := RegExReplace(_String,"\/|\\|\(|\)|\@|\!|\[|\]|\;|\+|\=|#|\$|\%|\^|\&","")
;---------------------------------------------------------------------- Title case options
;---------------------------------------------------------------------- Title case every word
_String := RegExReplace(_String,".*","$T0")
;---------------------------------------------------------------------- Title case the first letter only
; {
; StringLower, _String, _String
; FirstChar:=SubStr(_String, 1, 1)
; StringUpper, FirstChar, FirstChar
; _String:=SubStr(_String, 2)
; _String:=FirstChar _String
; }
;---------------------------------------------------------------------- Replacment
_String := listReplace( _String )
;---------------------------------------------------------------------- Replaces spaces among numbers with dots
_String:=RegExReplace(_String, "((\d+)\s+(?=\d))", "$2.")
;---------------------------------------------------------------------- Title case words after -
_String:=regexreplace(_String,"(-|- )(\w)","$1$T2")
;put the filename + extension in a string to check if theres a space before the ext.
output := _String . "." . _extension
ext_space := " ."
extreplace := "."
;return with extension if _flag is 0, for files.
;return the new string when _flag != 0, for folders.
}
rename(address)
{
;rename all files in open explorer window.
loop, %address%\*
{
output := Replace(A_LoopFileName, 0) ;output becomes the new filename.
path_to := A_LoopFileDir . "\" . output ;new dir + file name.
path_from := A_LoopFileDir . "\" . A_LoopFileName ;old dir + file name.
filemove %path_from%
, %path_to%
;rename the current file.
}
;rename all folders in open explorer window
loop, %address%\*,2,2
{
output := Replace(A_LoopFileName, 1) ;output becomes the new foldername.
path_to := A_LoopFileDir . "\" . output ;new dir + folder name.
path_from := A_LoopFileDir . "\" . A_LoopFileName ;old dir + folder name.
filemovedir %path_from%, %path_to% ;rename the current folder.
rename(path_to)
}
}
;---------------------------------------------------------------------- Execute Renamer
ifwinexist, ahk_class CabinetWClass
{
;get the path from an existing windows explorer window
;and remove the "address:" line from it.
;strip the invisible newline etc characters.
address := Strip( address )
rename(address)
}
;_________________________________________________________________________________________________
StringGetPos, lastline, filevar, `r`n, R
TrimMe := strlen(filevar) - lastline
FileAppend, %filevar%, Renamer.ahk
;_________________________________________________________________________________________________
SplashImage off
ExitApp
;---------------------------------------------------------------------- Replacment list
;!start
;1080I=
;Orenji=
;With Jon Stewart=
;Iplayer=
;Aac Dokus4alle=
;H264=
;The The=The
;bbc=BBC
;Www Mvgroup Org=
;Mvgroup Org=
;En De Fr=
;Xvid Ac3=
;Pdtv=
;Xvid Mp3=
;X264=
;Multi Audio=
;Ac3=
;Divx=
;Xvid=
;Ws Ekolb=
;Aac=
;Dvb=
;[Desibbrg Com]=
;Discovery=Discovery Channel
;Channel Channel=Channel
;Channel Channel=
;Channel - Channel=Channel
;Mvgroup Forum=
;Docs4you=
;Ch4=Channel 4 -
;Momentum=
;Mpeg2=
;Dd2=
;0 Ctrl=
;ws ftp=
;hitler=Hitler
;pill poppers=Pill Poppers
;BBC - BBC Horizon=BBC Horizon
;3 511=3
;omicron=
;xivd=
;Kere wsilluminatenboard org=
;!F9::=
;!F9::=
;xitApp=
;SetWorkingDir %A_ScriptDir%=
;mvgroup=
; ws=
;dts wiki=
;-.=-
;dvdr=
;Nl=NL
;Sp2=SP2
;Mi2=
;Richard Dawkins=Richard Dawkins -
;hdtdi=How Do They Do It -
;,= -
;Dd5 1=
;Ctrl=
;tv=
;Pbs=PBS
;Ftp=
;Dvsky=
;Readnfo=
; Hd=
;1180=Sahin
;x264=
;HDTV=
;264=
;BBC Horizon=BBC Horizon -
;Sfm=