Skip to content

Instantly share code, notes, and snippets.

@drakulaboy
Created August 15, 2023 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakulaboy/48dde2d6a4614164e4118faf7a89eb9d to your computer and use it in GitHub Desktop.
Save drakulaboy/48dde2d6a4614164e4118faf7a89eb9d to your computer and use it in GitHub Desktop.
Move files that have cyrilic letters in test2 folder
$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