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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -