Is there a way to move multiple files until other folders faster

Fabio Sancho-Davila 21 Reputation points
2020-09-27T22:46:59.9+00:00

My family has a camera security system and we use a code that downloads all of our videos and puts them into their respective folders. The videos aren't separated into folders for their specific dates. We haven't moved the files to their dated folders in over a month and it is taking too much time. I was able to find a code a few months ago to help change files names by selecting what I wanted to be replaced and with what I wanted to be replaced with. I would like to do something similar like finding all videos that have "08_27" and moving them to a folder that is dated for the 27th without having to go back and forth between folders to move them. I am using Microsoft Powershell. Please, anything would help.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-09-28T08:05:46.113+00:00

    Hi,

    Does this work for you?

    $SrcPath = "C:\source"  
    $DestPath = "C:\destination"   
    $Date = "08_27"    
    Set-Location $SrcPath  
    New-Item -ItemType Directory -Path "$DestPath\$Date" -force   
    Get-ChildItem -Path $Path -File -Recurse -Name *$Date* | Move-Item -Destination "$DestPath\$Date" -force  
    

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2020-09-28T01:52:14.917+00:00

    Maybe not exactly what you want, but try this:

    Get-ChildItem X:\folder\*98_27* -File |
        ForEach-Object{
            Move-Item $_.FullName -Destination "X:\new-directory\$($_.Name)"
        }
    

    Try it with "test" directories and only a few files to verify it does the correct thing!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.