Swap File Names Around RRS feed

  • Question

  • Hello All,

    I need to bulk rename files through PowerShell, right now they are named "Lastname Firstname.jpg".  

    How can I swap them around to be "Firstname Lastname.jpg".

    Thanks for your help. 

    Tuesday, October 24, 2017 2:26 PM

All replies

  • Is this a homework question.  renaming that way will make the files un-sortable.

    Just split the name and swap the parts.

    $lastname,firstname = $_.Basename -split ' '
    "$firstname $lastname"


    Tuesday, October 24, 2017 2:41 PM
  • No its not a homework question.  I need to have the file names of a few hundered pictures to match AD names. So having to type in every name to powershell wouldn't be any faster than just manually changing each name one by one. 
    Tuesday, October 24, 2017 3:35 PM
  • Then you have the answer above.

    Keep PosHing.


    Tuesday, October 24, 2017 5:04 PM