Python Forum
Is there a *.bat DOS batch script to *.py Python Script converter?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a *.bat DOS batch script to *.py Python Script converter?
#1
I consider to convert some of my long term *.bat batch scripts (on Windows) to a corresponding *.py Pythoin script.

Is there a reliable converter tool to perform this task automatically?
Reply
#2
Sure AI(eg ChatGPT) will do this task fine,with detailed explanation.
If you know what batch scripts do,then is fine training to do them manually over to Python.
There are module that for surly will be used like eg:os, subprocess, shutil ,pathlib(try to use this mostly over os),
so it good to know something about them.
Can also look into command-line interface (CLI) as i eg use in this post.
Reply
#3
Recent discussion of shell commands on the PythonBytes podcast you might check out. Python Bytes episode 341
Reply
#4
Yes, there are tools available that can convert DOS batch scripts (.bat) to Python scripts (.py). One such tool is called "bat2py," which is a command-line utility specifically designed for this purpose. It can analyze a batch script and generate an equivalent Python script.

Here are the steps to convert a batch script to a Python script using bat2py:

Download and install the "bat2py" utility. You can find it on the official website or various online repositories.

Open a command prompt or terminal and navigate to the directory where the batch script (*.bat) is located.

Run the following command to convert the batch script to a Python script:

bat2py your_script.bat

The utility will analyze the batch script and generate a corresponding Python script with the same name but with a .py extension.

For example, if your batch script is named example.bat, the converted Python script will be example.py.

Please note that the conversion process may not always result in a direct one-to-one translation, as batch scripts and Python scripts have different syntax and capabilities. Therefore, manual adjustments to the converted Python script may be necessary, depending on the complexity and functionality of the original batch script.

Here is sharing some link removed may be its helpful to you.







Regenerate response
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 417 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  Using a script to open multiple shells? SuchUmami 9 542 Apr-01-2024, 10:04 AM
Last Post: Gribouillis
  How to include one script into another? MorningWave 8 501 Mar-21-2024, 10:34 PM
Last Post: MorningWave
  ChromeDriver breaking Python script genericusername12414 1 321 Mar-14-2024, 09:39 AM
Last Post: snippsat
  using PowerShell from Python script for mounting shares tester_V 8 549 Mar-12-2024, 06:26 PM
Last Post: tester_V
  No Internet connection when running a Python script basil_555 8 663 Mar-11-2024, 11:02 AM
Last Post: snippsat
Question Running Python script through Task Scheduler? Winfried 8 525 Mar-10-2024, 07:24 PM
Last Post: Winfried
  currency converter using forex-python preethy12ka4 8 731 Mar-08-2024, 06:59 PM
Last Post: preethy12ka4
  Combine console script + GUI (tkinter) dejot 2 436 Feb-27-2024, 04:38 PM
Last Post: deanhystad
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 360 Feb-17-2024, 12:29 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020