Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Bulk Convert .TXT Files to Unicode

Reply
 
Old 11-18-2008   #1 (permalink)
bwilde


 
 

Bulk Convert .TXT Files to Unicode

Hello,

I have a directory containing 300 .txt files in ANSI that I need
converted to Unicode. Rather than opening each file in Notepad and
saving as Unicode, I'm *really* hopeful that there's a smarter way to
do this.

Can somebody point me to a script (or other technique) that could save
me a ton of time?

Thanks!

-Ben

My System SpecsSystem Spec
Old 11-18-2008   #2 (permalink)
Jason


 
 

Re: Bulk Convert .TXT Files to Unicode

On Nov 18, 3:52 pm, bwi...@xxxxxx wrote:
Quote:

> Hello,
>
> I have a directory containing 300 .txt files in ANSI that I need
> converted to Unicode. Rather than opening each file in Notepad and
> saving as Unicode, I'm *really* hopeful that there's a smarter way to
> do this.
>
> Can somebody point me to a script (or other technique) that could save
> me a ton of time?
>
> Thanks!
>
> -Ben
Assuming ALL of the files in the directory are ANSI and you want to
convert them all.
If all of the files in the directory are your text files you can get
rid of the If statement.
This should do the trick.

Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder("C:\Temp")
Set oFiles = oFolder.files

For each file in oFiles
If Right(file.Name, 3) = "txt" Then
Set ANSIFile = fso.OpenTextFile(file.path, 1, False, False)
ANSIContent = ANSIFile.ReadAll
Set UNICODEFile = fso.OpenTextFile(file.path, 2, False, True)
UNICODEFile.Write ANSIContent
End If
Next
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Bulk Unblock of Files PowerShell
display unicode (utf-8) files in Windows Console PowerShell
Convert Windows-1255 RSS to unicode, so I can call loadXML VB Script
How to Bulk Unblock Files Vista file management
How to Bulk Unblock Files Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46