Author Posts

August 15, 2017 at 8:14 pm

I have a shared folder with over a million files into it, is there a way to split the contents into many smaller folders ?

August 15, 2017 at 9:16 pm

You might try New-Item to create additional directories to split/move the items into, and then use Move-Item to move certain items to the folders/subfolders you create. With a million files, you'll probably want to use the -Filter parameter, of the Move-Item cmdlet, to get a subset of the files that you want to move to a particular folder.

August 15, 2017 at 9:19 pm

You can use the same -Filter parameter on Get-Item, storing the results into a variable, and then dumping out the variable to make sure you will be moving the items you want to move to a particular folder/subfolder. You can then pipe the variable to the Move-Item cmdlet.

August 15, 2017 at 10:43 pm

I would think using a variable may use a lot of memory, try piping from the get-item directly to the move-item, it should be more memory efficient.

August 15, 2017 at 11:17 pm

That's definitely possible, but before running a Get/Move script, with guns-a-blazing, on a million files it's good to verify that the right set of objects will be affected by the Move-Item cmdlet. If the filter can be fine-tuned enough, for a test, that would be the best thing before running the code on the full set.