Login | |
|
 |
RE: Script to rename lots of folders - 5/17/2006 7:15:15 AM
|
|
 |
|
| |
thinicer
Posts: 18
Score: 0
Joined: 5/17/2006
Status: offline
|
Hey ehvbs, I guess I spoke too soon. While the script works, I didn't count on something else. All these folders are on a DFS. The script I made, instead of replicating just the simple file name change (2 KB), it is replicating ALL of the data in the folders, gigs and gigs worth. Do you know if any way to write a script that will just do a simple name change but won't replicate all the data in the folders? If I were to do this manually, by highlighting the folder and manually changing the name using explorer, it would not force a complete replication. Here is the script I'm working. Most of the code comes from another post on this forum: Dim fso,f,fc Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("c:\test") Set fc = f.SubFolders For Each f1 in fc RenameFolder(f1.Name) Next Sub RenameFolder(folder) 'Will rename directory to new naming convention strOldname = folder strNewFolder = Left( strOldName, 2 ) + Mid( strOldName, 4, 4 ) + ".00" + Mid( strOldName, 8 ) f1.Name = strNewFolder End Sub Would be great if it didn't replicate all the data! Thanks for all your help with this. - Michael
|
|
| |
|
|
|
 |
RE: Script to rename lots of folders - 5/17/2006 8:19:09 AM
|
|
 |
|
| |
ebgreen
Posts: 5070
Score: 31
Joined: 7/12/2005
Status: online
|
Change this: Set f = fso.GetFolder("c:\test") to this: Set oWSHl = WScript.CreateObject("WScript.Shell") strPWD = oWSHl.CurrentDirectory Set f = fso.GetFolder(strPWD)
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Script to rename lots of folders - 5/19/2006 1:50:07 AM
|
|
 |
|
| |
thinicer
Posts: 18
Score: 0
Joined: 5/17/2006
Status: offline
|
It's kind of hard to explain since I don't know DFS that well, but I will give it my best shot. When you set up DFS you have to specify a root of all the data you want to replicate. For example, suppose I want to replicate data all data in the D:\DFSdata\ on my server. D:\DFSdata is therefore the root. Now, the script I was using before specified a path, so if I wanted to change all the folder names in D:\DFSdata\Work\Projects I would have to put that path in the script and I could theoretically run from the script from another folder or another drive if I wanted. Because of the way DFS is configured, and because that script I was using before uses a path, it goes up the tree. It goes to DFSdata, and then goes to Work, and then goes to Projects and changes the path of the folders from the ROOT itself. So, it changes D:\DFSdata\Work\Projects\Old Folder Name to D:\DFSdata\Work\Projects\New Folder Name. So when it did these changes, it just began replicating all the data on the server for some reason because the root was included in the path. The new script that ebgreen assisted me with runs from within the folder it is located in, so the only path it concerns itself with where it is located onwards. It runs from the current folder, kind of like running an executable where it is located instead of just using a shortcut on your desktop. That's the best way I can describe it.
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|