Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: AutoIt | Size: 0.89 KB | Hits: 50 | Expires: Never
Copy text to clipboard
  1. rename(address)
  2. {
  3.         ;rename all files in open explorer window.
  4.         loop, %address%\*
  5.         {
  6.                 output := Replace(A_LoopFileName, 0)                            ;output becomes the new filename.
  7.                 path_to := A_LoopFileDir . "\" . output                         ;new dir + file name.
  8.                 path_from := A_LoopFileDir . "\" . A_LoopFileName       ;old dir + file name.
  9.                 While (FileExist(path_to . a))
  10.                         a := "_" . A_Index
  11.                 filemove %path_from%, %path_to%%a%                                              ;rename the current file.
  12.         }
  13.  
  14.         a := ""
  15.         ;rename all folders in open explorer window
  16.         loop, %address%\*,2,2
  17.         {              
  18.                 output := Replace(A_LoopFileName, 1)                            ;output becomes the new foldername.
  19.                 path_to := A_LoopFileDir . "\" . output                         ;new dir + folder name.
  20.                 path_from := A_LoopFileDir . "\" . A_LoopFileName       ;old dir + folder name.
  21.                 While (FileExist(path_to . a))
  22.                         a := "_" . A_Index
  23.                 filemovedir %path_from%, %path_to%%a%                                   ;rename the current folder.
  24.                 rename(path_to)
  25.         }
  26. }