Help renaming folders recursively

Author Message
TDiLisio

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 11/29/2011
  • Status: offline
Help renaming folders recursively Tuesday, November 29, 2011 4:31 AM (permalink)
0
Hi Folks.
I have a folder structure where I need to rename each folder and subfolder to a portion of its existing name.
The sub folders contain various type of PDF, DOC and XLS files that I cannot rename.
The existing folders that I need to rename all have a dot 6 digit numerical extension... like "d:\subdir\folder-name.xxxxxx" or "d:\subdir\folder name.xxxxxx" or "d:\subdir\folder-name.xxxxxx\folder name.xxxxxx\folder name name1.xxxxxx" where xxxxxx = random numerical digits.
 
I need to rename each folder in the structure to just the numerical extension... so I end up with d:\subdir\xxxxxx\xxxxxx\xxxxxx... and so on.
 
Unfortunately I have no experience with any kind of scripting. I did look at the sample scripts on this site. I actually ran one  that recursively listed the folder structure that I need to change (and displayed the results in a window that I had to click OK on) ... but thats as far as my knowledge will get me.
Can/Should this be done using VBScript?   If so... how?
I wasn't able to find a similar scenario/request on this site.

I appreciate any assistance.
Thanks.
<message edited by TDiLisio on Tuesday, November 29, 2011 5:37 AM>
 
#1
    59cobalt

    • Total Posts : 972
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: online
    Re:Help renaming folders recursively Tuesday, November 29, 2011 12:08 PM (permalink)
    0
    Traversing a directory tree can be done via folder recursion. Check the FAQ. Renaming the folders can probably be done like this, according to your rules:
    Set re = New RegExp
    re.Pattern = "\.[0-9]{6}$"
    
    If re.Test(objFolder.Name) Then objFolder.Name = Right(objFolder.Name, 6)

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9