Last active
November 7, 2018 11:01
-
-
Save skkut/b920cd146b3abe80c6c634ab8da9ef51 to your computer and use it in GitHub Desktop.
Identify files that are not backed up and move them to a new sub folder. Already backed up filenames are in filelist.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dir = 'D:\sample_folder' | |
$FileList = $dir + '\filelist.txt' | |
$BackupFolderName = (get-item $dir).BaseName + " Backup" | |
$BackupFolder = Join-Path $dir $BackupFolderName | |
New-Item -ItemType Directory -Force -Path $BackupFolder | |
$BackedFiles = Get-Content $FileList | |
$Files = Get-ChildItem -Path $dir -File | |
foreach ($file in $Files) | |
{ | |
if($BackedFiles -notcontains $file.Name) | |
{Move-Item $dir\$file $BackupFolder} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment