Created
August 15, 2023 14:00
-
-
Save drakulaboy/48dde2d6a4614164e4118faf7a89eb9d to your computer and use it in GitHub Desktop.
Move files that have cyrilic letters in test2 folder
This file contains 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
$source = "E:\Muzon\CAR Music\rus" | |
$destination = Join-Path -Path $source -ChildPath "test2" | |
$filter = "*.*" # Change this to match the desired file extensions | |
$filesWithCyrillic = Get-ChildItem -Path $source -File | Where-Object { $_.Name -match "\p{IsCyrillic}" -and $_.Name -like $filter } | |
# Create the destination directory if it doesn't exist | |
if (-not (Test-Path -Path $destination)) { | |
New-Item -Path $destination -ItemType Directory | |
} | |
$filesMoved = 0 | |
$filesWithCyrillic | ForEach-Object { | |
$newDestination = Join-Path -Path $destination -ChildPath $_.Name | |
Move-Item -Path $_.FullName -Destination $newDestination -Force | |
$filesMoved++ | |
} | |
Write-Host ("MOVED " + $filesMoved + " files to test2 directory") -ForegroundColor Yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment