windows 7 - Powershell to Script to Add Part of a Grandparent Folder to Child Item Names -
at work, maintain large (500+) file system of company's clients. each client has own folder, subfolders years, , account files in each year folder. on client's folder, their name , six-digit identifier number. facilitate upcoming audit, asked attach 6 digit identifier number on grandparent folder each of child item account files. there way specify portion of grandparent's folder add child item? if so, script?
p.s. apologize, new coding, i'm actively trying learn powershell.
sounds need learn regular expressions.
$grandparent = 'c:\bobby 123456\2014\bobby 15-5555' if ($grandparent -match 'c:\\(?<name>.*)\s(?<idcode1>\d{6})\\(?<year>\d{4})\\.*\s(?<idcode2>\d{2}-\d{4})'){ $matches.name $matches.idcode1 $matches.year $matches.idcode2 "{0} {1} {2}" -f $matches.name,$matches.idcode2,$matches.idcode1 }
here favorite reference regex.
Comments
Post a Comment