[PowerShell code] Remove non-English letters from files

If you try to download some non-ASCII files from the Internet, you will find no problems on this machine, but when you transfer the files to other places or other computers, you will find that there are bigger problems. How can I transfer the files to other places or computers? How to remove non-English letters in these files?

How can I remove these non-English letters from the file? I wrote the following PowerShell code for your reference. After execution, you will find that the code can directly remove non-English letters.

$allfile=Get-ChildItem "C:\Users\xupeng\Videos\One Skill PowerPoint"


foreach($file in $allfile)
{

$basename=$file.BaseName.ToCharArray()

$newfilename=" "
foreach($character in $basename)
{
if([int]$character -gt 122)
{

$newfilename+=""
write-host [int]$character
}
else
{
$newfilename+=$character
}

}
$newfilename=$newfilename+".mp4"

rename-item -Path $file.FullName -NewName $newfilename


}

Guess you like

Origin blog.csdn.net/fogyisland2000/article/details/132765789