none
how to change file name to folder name RRS feed

  • Question

  • Hi Guys

      I have a folder constructed as below

      c:\folder\userA;

      c:\folder\userB;

      c:\folder\userC;

      and so on, and in each usrX foler, there was local.csv file , so now what i want was to change the local.csv in each folder to the usera.csv , userB.csv and so on , can powershell do this ?

    • Moved by Bill_Stewart Friday, November 28, 2014 5:25 PM Unanswerable help vampire question
    Tuesday, November 4, 2014 1:52 AM

Answers

All replies

  • Absolutely.  PowerShell is perfect for changing things.

    Start here: http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    Post back with specific questions.


    ¯\_(ツ)_/¯

    • Proposed as answer by jrv Tuesday, November 4, 2014 2:22 AM
    • Marked as answer by Just KarlModerator Thursday, April 30, 2015 4:52 PM
    Tuesday, November 4, 2014 2:22 AM
  • Here is a hint as to how to do this but ther is not enough information to determine exactly how to do it.

    dir c:\rootfolder -directory |
         ForEach-Object{
               rename-item "$($_.Fullname)\local.csv" "$($_.Basename).csv"
         }


    ¯\_(ツ)_/¯


    • Edited by jrv Tuesday, November 4, 2014 2:36 AM
    Tuesday, November 4, 2014 2:35 AM