Run Windows batch files (.bat) using Python
Project description
Batchfile.py
A Python library to execute simple batch files (.bat) that would normally only work on Windows. After installing, you can get a REPL (live commandline) to test by running python3 -m batchfile
When I was in high school I used to write text adventure games using Windows batch files. In October 2020 I wrote a Python script to interpret the batch files. This is a fun experiment to see if I can get unaltered original batch file games to play on Ubuntu using Python without introducing too much complexity.
See my bat2web repo for an example of how you can use this library to turn a batch file into a website. Something you've always wanted to do, surely :)
How to play
- Install library by running
pip install .
in the same folder as thesetup.py
file. - Go in the
/games
directory for python scripts that will launch games. - So far the only supported game is one I wrote when I was 16, which you can play by running
funtimes.py
using Python 3.6+ on Linux, Windows, or MacOS. - On Windows you can also play the original game without Python using
FUNTIMES.bat
inside the funtimes directory - The original game actually works using
wineconsole
in Ubuntu as well, except for rare math problems - Funtimes can also be played in a web browser
Running other batch files
I definitely don't intend to support every batch file, but it would be nice if similar batch-file-games worked without introducing too much complexity. Another game I wrote in 2010 called "Recruitment" is included as an example, but it doesn't yet work. Ultimately it would be really cool if this library supported Time Streamer.
The main obstacle to most games working is the lack of support for parentheses and quotation marks. Some hacky solutions are included to deal with the simple cases in Funtimes, but eventually I have to write a tokenizer/lexer to correctly deal with these complex structures. This should greatly increase compatibility once I do that!
Another obstacle is that a lot of batch files use weird .EXE or .COM files that do various tasks, but when I discover these cases I'll try to include them as standard functions. My primary goal is supporting batch file games, so I'm not worried about if something is a "pure" batch file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file batchfile.py-0.5.tar.gz
.
File metadata
- Download URL: batchfile.py-0.5.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4042902840057ecc9c3c98cd0fb75b5399e460c05bc08dffcaee684d4ed19a |
|
MD5 | 1c8e3bfa757ff42962c2fac52260a2d4 |
|
BLAKE2b-256 | dbf213334e4477dad19d14a6a311fe2dd4ab59e5d2e5411d93c74f005f7b5a04 |
File details
Details for the file batchfile.py-0.5-py3-none-any.whl
.
File metadata
- Download URL: batchfile.py-0.5-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 257516fdfb79875b2b3d970d10da48e7c9e15d11b2facd331694e4817bf29a14 |
|
MD5 | 13143b815cc66fa6b16e70551f994094 |
|
BLAKE2b-256 | dbd5b6195af39f691875026cdd65233daf88ffffd05120a626706eb2de4b162b |