I need to rename a lot of directories and their sub directories.
I have a csv file which contains the old directory names and the required new name.
1,blah,old_name1,new_name2,wibble
2,foo,old_name2,new_name2,bar
3,john,old_name3,new_name3,paul
4,george,old_name4,new_name4,ringo
Note that some of the directory names are
old_name1-morestuffhere
which need to be renamed to
new_name1-morestuffhere
I know broadly how I'd do this in bash:
mv -r `cat file.csv | awk -F, '{print $3* $4*}'`
..but I'm bound to and totally lost with powershell.
EDIT: Here's what I've got so far. Is this close?:
cat .\file.csv | foreach { $oldname = $_.split(",")[2], $newname = $_.split(",")[3], move-item $oldname*, $newname*}