locked
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

    "------------------------"\document2.png

    "------------------------"\document3.pdf

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

    "------------------------"\document5.png

    "------------------------"\document6.pdf

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

    "------------------------"\document2.png

    "------------------------"\document3.pdf

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

    "------------------------"\document5.png

    "------------------------"\document6.pdf

    Desired outcome

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

    "------------------------"\123-document2.png

    "------------------------"\123-document3.pdf

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

    "------------------------"\123-document5.png

    "------------------------"\123-document6.pdf

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

    "------------------------"\456-document2.png

    "------------------------"\456-document3.pdf

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

    "------------------------"\456-document5.png

    "------------------------"\456-document6.pdf

    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.

    Thanks,


    Wednesday, April 25, 2018 2:56 PM

All replies