# Find and rename folders with (1), (2), (3) in the name and merge all 3 with the original

 #1 : 06/05-19 19:04 Bill Warren Posts: 2 I have a folder with thousands of nested subfolders in which there were Duplicates that were named Folder, Folder (1), Folder (2), Folder (3) I want to rename the folders that have the (1), (2), (3) and merge into the original folder. I realize that this can be done manually but there are 200-300 some odd instances of this. I was hoping this would be able to handle this procedure. I set up the pattern as a rename \ $$\d$$ I have the Name Collision Rule to ignore. Could you suggest any ideas how I might achieve this with Advanced Renamer? 06/05-19 19:04
 #2 : 07/05-19 08:47 David Lee Posts: 164 I don't think that this is possible using Advanced Renamer. However it can be achieved easily using a Windows batch file: @Echo off pushd "C:\path\to\your\base\folder" for /f "Tokens=1* Delims=(" %%A in ( 'Dir /B /AD *(*' ) Do If Not Exist "%%A" ( Ren "%%A(%%B" "%%A" ) Else ( Move /Y "%%A(%%B\*" "%%A\" RmDir "%%A(%%B" ) PopD The batch parses the output of the dir by splitting the dir names at the delimiter "(", %%A being the first token and %%B the remainder. If a dir like the first token doesn't exist it is renamed, if it does the content of the long-named dir is forcibly moved and the dir removed afterwards. Edit the path to suit your environment. I can't claim any credit for this solution - the code and explanation is adapted from: https://superuser.com/questions/1164961/how-to-m erge-folders-with-similar-names-with-a-b atch-file However I have tested it and it works for me. 07/05-19 08:47 - edited 07/05-19 08:57