Moving folders in/to differnt locations in a parent folder

Welcome Forums General PowerShell Q&A Moving folders in/to differnt locations in a parent folder

Viewing 1 reply thread
  • Author
    Posts
    • #178362
      Participant
      Topics: 2
      Replies: 5
      Points: 49
      Rank: Member

      I have different project folders that all have the same set of folders (all folders are not named exactly the same unfortunately). I've been trying to use the following code below to move them but keep getting an error:

      #Wildcards used in path because folder names not all standardized, 
      #I set my location to the project root folder.
      #Sets variable to project folder path
      $ProjectRootFolder=Get-Location
      
      #Moves desired files to Admin Folder
      Move-Item .\Briefs,'.\Budget Formulation','.\Fact Sheets',.\Images,.\Reports -Destination .\*Admin*
      
      #change directory, goes through all FYs for the Budget Formulation folder. These folders and it's subfolders were moved with the #previous code
      cd $ProjectRootFolder"\*Admin\*Budget Formulation*\*20*\Contract formulation documents"
      Move-Item ".\Phasing Plan',.\Proposals,.\SOW,'.\SRRB Quad chart','.\UFR - CYD' -Destination $ProjectRootFolder"\*Admin*\*Budget Formulation*\*20*"
      
      cd $ProjectRootFolder"\*Admin\*Budget Formulation*\*19*\Contract formulation documents"
      Move-Item ".\Phasing Plan',.\Proposals,.\SOW,'.\SRRB Quad chart','.\UFR - CYD' -Destination $ProjectRootFolder"\*Admin*\*Budget Formulation*\*19*"
      
      cd $ProjectRootFolder"\*Admin\*Budget Formulation*\*18*\Contract formulation documents"
      Move-Item ".\Phasing Plan',.\Proposals,.\SOW,'.\SRRB Quad chart','.\UFR - CYD' -Destination $ProjectRootFolder"\*Admin*\*Budget Formulation*\*18*"

      ERROR

      Move-Item : A positional parameter cannot be found that accepts argument '\*Admin*\*Budget'.
      At line:12 char:1
      + Move-Item ".\Phasing Plan',.\Proposals,.\SOW,'.\SRRB Quad chart','.\U ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (:) [Move-Item], ParameterBindingException
          + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.MoveItemCommand

      Is it all the wildcards? I'm not very experienced with powershell or coding in general. Any other info needed please let me know.

    • #178389
      Participant
      Topics: 1
      Replies: 9
      Points: 84
      Helping Hand
      Rank: Member

      Hi,

      Does this help? please focus on the double quotes "

      
      Move-Item ".\Phasing Plan",".\Proposals",".\SOW",".\SRRB Quad chart",".\UFR – CYD" -Destination $ProjectRootFolder"\*Admin*\*Budget Formulation*\*18*"
      
      

      I tried to repro the error you are having, and I did not face any other issue due to the wildcards.

       

      • #178998
        Participant
        Topics: 2
        Replies: 5
        Points: 49
        Rank: Member

        Thank you James. I just realized it was just a formatting error on my part, Looks like I put the path in double quotes on one sie and single on the end ("Path\sub Folder\file'). The error is gone now!!

Viewing 1 reply thread
  • The topic ‘Moving folders in/to differnt locations in a parent folder’ is closed to new replies.