Mass rename files based on table

cnfuzzdcnfuzzd Member Posts: 208
Hi All

We have a series of images that have been assigned new product names. The relationship between old and new is contained both in a spreadsheet and in a sql table. Is there any magic (powershell etc) out there that can automatically rename the file from the original name to the new name assigned in the table? I don't think I am stating this very clearly, so let me know where I can shore it up.

Thanks!

John
__________________________________________

Work In Progress: BSCI, Sharepoint

Comments

  • wd40wd40 Member Posts: 1,017 ■■■■□□□□□□
    some excel vbs should solve your problem

    EXCEL ::
  • EveryoneEveryone Member Posts: 1,661
    Yes, you can do it with PowerShell. Create a .csv file in Excel with something like "Oldname" in column A, and "Newname" in column B.
    Put all the names in the appropriate columns under them.

    Create a script called renamefiles.ps1 or whatever you want to call it. Code in it should be like this:


    $filepath = "<location of the files you want renamed>
    $data = Import-CSV <path to your .csv file here>
    ForEach ($line in $data)
    {
    Rename-Item $filepath\$line.Oldname $line.Newname
    }



    Run the script. Should work.
Sign In or Register to comment.