regex - Powershell Move file from directory to subdirectory based on filename -
I would like to use all 8k + files once because the left 5 characters of the file correspond to the correct 5 sub -To transfer the directory.
This one works one by one:
move-item-path X: \ "property files \" \ 05165 * .pdf -destination X: \ " Property Files "\" * - 05165 "; Move-item-path X: \ "asset files \" \ 05164 * .pdf -destination X: \ "asset files" \ "* - 05164"; Thanks in advance for any help.
One-liner, as one, already exists, assuming the destination folder:
Go-ChildItem "X: \ Property Files * .pdf" | Unit {step-path $ _ - dynamics ($ _ directory name + "\ * -" + $ _. Name.substring (0,5))} Use only filename Do it, you just remove the first five letters ( substring (0,5) ), then use it as the end of the folder to match.
$ _ directory name Accept the destination folder is a subfolder of the source path.
Comments
Post a Comment