Announcement

Collapse
No announcement yet.

renaming folders script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • renaming folders script

    Hi Guys,

    This there a way I can rename folder using a bat file.

    Basically I have roaming profiles which the users prfile folder is in the follwing format firstname lastname

    I want to rename to
    firstname.lastname

    Is there a way I can create a batch file to replace all spaces with a . rather than manually change everyone

    Thanks in advance

  • #2
    Re: renaming folders script

    A batch could get the user's first and last name from AD. And use these names for the new name of the profile folders.
    The first name or the lastname of a user can contain embedded spaces, would you like to replace all spaces into dots?

    How are the currently existing individual profile folders created, by the system by script? Is that still active?

    Do you want to change the current profile path that is configured on the profile path tab at the properties of the User objects in Adtive Directory, before renaming the fysical folder on the server? A batch can use dsquery | dsmod for this.

    Is the Location of the My Documents Folder Redirected Outside of the Userís Roaming Profile?


    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: renaming folders script

      here's a vbscript to rename directories with spaces to "." recursively. modify to suit your environment

      Code:
      Set objFS = CreateObject("Scripting.FileSystemObject")
      strFolder = "c:\test"
      Set objFolder = objFS.GetFolder(strFolder)
      Go (objFolder)
      Sub Go(objDIR)
        If objDIR <> "\System Volume Information" Then
          For Each eFolder in objDIR.SubFolders
              strFolderName = eFolder.Name        
              If InStr(strFolderName ," ") > 0 Then
                  WScript.Echo strFolderName
                  strFolderName = Replace(strFolderName," ",".")
                  eFolder.Name = strFolderName
              End If 
                Go eFolder
          Next
        End If  
      End Sub

      Comment


      • #4
        Re: renaming folders script

        Originally posted by ghostdog74 View Post
        here's a vbscript to rename directories with spaces to "." recursively. modify to suit your environment
        Hi ghostdog,
        I am not sure if your solution do what was being asked.

        Anyhow,
        I would like to bring again extra to anyone's attention, by running this sample script from the previous reply against the user's profile folder the script will irreversible repace recursively any space in the names of all subfolders to a dot, subfolders that exist within a profile folder.

        AFAIK The question was howto change just the users profile folder; first change the order of firstname lastname THEN replace the space that separates the names into a dot (just for that folder only).

        Note that the user's profile folder is a systemfolder, you'll have to make somes changes to the system as well!

        @steffan,
        Does Domain Admins have sufficient permissions to rename the name of the user's profile folder on de server?


        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: renaming folders script

          @REM, the first post from OP clearly states that he need to replace spaces to dot. Hence, i only create the vbscript to do just that.
          also, i don't see him mention he need to change the order of the names. As for doing it recursively, if its not what he wants, he can also remove the
          Code:
          Go eFolder
          statement.

          Comment


          • #6
            Re: renaming folders script

            Originally posted by ghostdog74 View Post
            i don't see him mention he need to change the order of the names. As for doing it recursively, if its not what he wants, he can also remove the
            Code:
            Go eFolder  (line 14)
            statement.
            Hi ghostdog,
            My bad reading, the names don't have to be reordered first. Thanks for the heads up!

            Still, I like to remark that one can not just change the name of the fysical folder without configuring the new name into the user's system settings too, because the user profile folder is a system folder.

            Further more,
            The permissions on the user's profile base folder could be " Creator cannot change folder" and " Domain Admins have non permission" .
            @steffan, could you check the permissions on the user folders. And can you tell also how the profile folders are being created for each new user.


            \Rems

            This posting is provided "AS IS" with no warranties, and confers no rights.

            __________________

            ** Remember to give credit where credit's due **
            and leave Reputation Points for meaningful posts

            Comment

            Working...
            X