Powershell set field value based on folder name

I need to find a way using Powershell to set the value of a field in a document library based on a folder name. So for example if there is a folder called “00170” and there is a field named “Reference”, I would like the value of “00170” set to this field.

I have little to none scripting skills so would appreciate some help with this.