Pages

Showing posts with label how to rename folder using script. Show all posts
Showing posts with label how to rename folder using script. Show all posts

Friday, 8 June 2012

Rename Folders using VBScript

Following script renames the folder in each user profile on WindowsXP machines


Dim FSfolder
Dim subfolder
Dim i

set objshell = CreateObject("Wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

SysDrv=objshell.ExpandEnvironmentStrings("%systemdrive%")


Profile = SysDrv & "\Documents and Settings"
Set FSfolder = FSO.GetFolder(Profile) 'getting the user profile folders


'starting of the loop to delete the HKCUs

For Each subfolder In FSfolder.SubFolders

   If (subfolder.Name <> "All Users" And  subfolder.Name <> "Default User"_
   and subfolder.Name <> "LocalService" and subfolder.Name <> "NetworkService") Then

folder1=Profile & "\" & subfolder.Name & "\Application Data\Documentum\Client for Outlook"



RenameFolder(folder1)



   end if

Next

'*******************************************************************************************************

Function  RenameFolder(FolderName)

    If FSO.FolderExists(FolderName) Then
    'msgbox Foldername & ".old"
FSO.MoveFolder FolderName, Foldername & ".old"

    End If

End Function