Reputation: 25
I am having trouble searching a large directory of files for a string. The search command I'm using is skipping any file encoded in Unicode. I want to find all the files in this directory that are encoded in Unicode. I am on Windows XP.
Thank you!
Upvotes: 0
Views: 1523
Reputation: 7429
You can do it with my script below, the input does not care what encoding, as far as you specify the output encoding like this -Encoding ASCII
.
cd c:\MyDirectoryWithCrazyCharacterEncodingAndUnicode
Copy and past the script in your Powershell windows, you get the idea just play with it to fix the syntax
foreach($FileNameInUnicodeOrWhatever in get-childitem )
{
$tempEncoding = (Get-Content -encoding byte)
write-output $FileNameInUnicodeOrWhatever "has encoding" $tempEncoding
// [System.Text.Encoding]::$result
}
If you want to further resolve issues with not being able to find files because of encoding, change the encoding type
Upvotes: -1
Reputation: 16896
The find
command in Windows supports Unicode text files. findstr
doesn't.
Upvotes: 0
Reputation: 69652
You don't know encoding before you open a file and read from it. So you will enumerate directory files, then go through the list, open and check either BOM
or the content itself (such as certain amount of heading bytes).
Upvotes: 1