Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7052893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:26:18+00:00 2026-05-28T03:26:18+00:00

I have a batch script that prompts a user for some input then outputs

  • 0

I have a batch script that prompts a user for some input then outputs a couple of files I’m using in an AIX environment. These files need to be in UNIX format (which I believe is UTF8), but I’m looking for some direction on the SIMPLEST way of doing this.

I don’t like to have to download extra software packages; Cygwin or GnuWin32. I don’t mind coding this if it is possible, my coding options are Batch, Powershell and VBS. Does anyone know of a way to do this?

Alternatively could I create the files with Batch and call a Powershell script to reform these?

The idea here is a user would be prompted for some information, then I output a standard file which are basically prompt answers in AIX for a job. I’m using Batch initially, because I didn’t know that I would run into this problem, but I’m kind of leaning towards redoing this in Powershell. because I had found some code on another forum that can do the conversion (below).

% foreach($i in ls -name DIR/*.txt) { \
       get-content DIR/$i | \
       out-file -encoding utf8 -filepath DIR2/$i \
  }

Looking for some direction or some input on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:26:19+00:00Added an answer on May 28, 2026 at 3:26 am

    You can’t do this without external tools in batch files.

    If all you need is the file encoding, then the snippet you gave should work. If you want to convert the files inline (instead of writing them to another place) you can do

    Get-ChildItem *.txt | ForEach-Object { (Get-Content $_) | Out-File -Encoding UTF8 $_ }
    

    (the parentheses around Get-Content are important) However, this will write the files in UTF-8 with a signature at the start (U+FEFF) which some Unix tools don’t accept (even though it’s technically legal, though discouraged to use).

    Then there is the problem that line breaks are different between Windows and Unix. Unix uses only U+000A (LF) while Windows uses two characters for that: U+000D U+000A (CR+LF). So ideally you’d convert the line breaks, too. But that gets a little more complex:

    Get-ChildItem *.txt | ForEach-Object {
      # get the contents and replace line breaks by U+000A
      $contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n"
      # create UTF-8 encoding without signature
      $utf8 = New-Object System.Text.UTF8Encoding $false
      # write the text back
      [IO.File]::WriteAllText($_, $contents, $utf8)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, we have a script that creates batch files to XCOPY our
I have a batch script that dynamically creates some files and generates four files
I have a batch script I run before our performance tests that does some
I have a batch script that calls a process and currently it waits for
I have a nightly build DOS batch script that invokes devenv.exe to build a
I have a batch file containing a python script using the Output template> %(NAME)s
I have this batch that needs to run that the user has to execute
I have a sh/bash script that needs to call a batch file with parameters
I have a batch script that checks if a registry key exists and if
I have a batch script that I want to call from an MSBuild project,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.