Adding additional data to files and folders using PowerShell RRS feed

  • Question

  • Hi,

    We are looking to upload employee data from a file share to a cloud based application. The application is capable of looking at data to upload, but requires a unique tagging in each file and folder to ensure the data is placed in the correct destination within the application. We are using numbers to identify this data, however I need to apply this to both sub folders and files.

    Each file can have 20+ files but has/should have the same folder structure. I provided an example of the current layout and desired outcome

    Current Layout

    C:\Surname A\folder A\document1.docx



    "--------------"\folder B\document4.docx



    C:\Surname B\folder A\document1.docx



    "--------------"\folder B\document4.docx



    Desired outcome

    C:\123-Surname A\123-folder A\123-document1.docx



    "--------------"\123-folder B\123-document4.docx



    C:\456-Surname B\456-folder A\456-document1.docx



    "--------------"\456-folder B\456-document4.docx



    Research shows power shell can do this. and I so far have this command, and have tried playing with it (using -whatif) to do the above but I am struggling.

    Get-ChildItem | %{$_|rename-item -NewName ($_.DirectoryName +'\' + $_.BaseName + '-123' + $_.Extension) -whatif}

    This is brand new territory for me, having never used Powershell. I think I understand the logistics of the command, I just can't get it to.

    Any help or advice would be appreciate, but remember I'm a total 'noob' on this.


    Wednesday, April 25, 2018 2:56 PM

All replies