Untitled
By: a guest | Feb 9th, 2010 | Syntax:
AutoIt | Size: 0.89 KB | Hits: 50 | Expires: Never
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.
While (FileExist
(path_to
. a))
a := "_" . A_Index
filemove %path_from%
, %path_to%%a%
;rename the current file.
}
a := ""
;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.
While (FileExist
(path_to
. a))
a := "_" . A_Index
filemovedir %path_from%, %path_to%%a% ;rename the current folder.
rename(path_to)
}
}