Chris Barnes
Chris Barnes

Reputation: 25

In Windows, how do I find all files in a certain directory that are encoded using unicode?

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

Answers (3)

Transformer
Transformer

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.

  1. Goto the Dir you want cd c:\MyDirectoryWithCrazyCharacterEncodingAndUnicode
  2. Fire this script away!

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

arx
arx

Reputation: 16896

The find command in Windows supports Unicode text files. findstr doesn't.

Upvotes: 0

Roman Ryltsov
Roman Ryltsov

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

Related Questions