×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

script editing - base64 for files in folder

script editing - base64 for files in folder

script editing - base64 for files in folder

(OP)
Hi, the script only converts one file. Can you help me edit it for folder? Convert all files in the source folder to target folder (same file name as in the source folder). Thank you for your help.

Script:

inputFile = "D:\Folder\files_row_1_dmEncodedContent.blob"
outputFile = "D:\Folder2\files_row_1_dmEncodedContent.blob"

Set fso = CreateObject("Scripting.Filesystemobject")
Set input=fso.OpenTextFile(inputFile,1)
contents = input.ReadAll()
input.Close

Set oXML = CreateObject("Msxml2.DOMDocument")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = contents

Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1 'adTypeBinary
BinaryStream.Open
BinaryStream.Write oNode.nodeTypedValue
BinaryStream.SaveToFile outputFile

RE: script editing - base64 for files in folder

Hi,
Here is an working example how to process all files in a folder.
Modify and try the example, so it prints all file paths in your folders. Then relocate your code in the subroutine ConvertFile and it should do the work.

convert_files.vbs

CODE

inputFolder = "c:\folder"
outputFolder = "c:\folder2"

Set fso = CreateObject("Scripting.FileSystemObject")
countFiles = 0
for each file in fso.GetFolder(inputFolder).Files 
  inputFile = fso.BuildPath(inputFolder, file.Name)
  outputFile = fso.BuildPath(outputFolder, file.Name)
  call ConvertFile(inputFile, outputFile)
  countFiles = countFiles + 1
next
wscript.echo "Done. " & countFiles & " files converted."  

sub ConvertFile(inputFile, outputFile)
  wscript.echo "Converting """ & inputFile & """" & VbCrLF & _
               "        to """ & outputFile & """"
end sub 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close