Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would Python make a good substitute for the Windows command-line/batch scripts?

I've got some experience with Bash, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, so I was considering learning Python and using that instead.

Is Python suitable for such things? Moving files around, creating scripts to do things like unzipping a backup and restoring a SQL database, etc.

like image 487
Lawrence Johnston Avatar asked Oct 17 '08 20:10

Lawrence Johnston


People also ask

Can Python be used in CMD?

You can access Python in the Command Line by just typing python , python3 , or python3.

Can Python scripts run on Windows?

On Windows, the standard Python installer already associates the . py extension with a file type (Python. File) and gives that file type an open command that runs the interpreter ( D:\Program Files\Python\python.exe "%1" %* ). This is enough to make scripts executable from the command prompt as 'foo.py'.


1 Answers

Python is well suited for these tasks, and I would guess much easier to develop in and debug than Windows batch files.

The question is, I think, how easy and painless it is to ensure that all the computers that you have to run these scripts on, have Python installed.

like image 160
gnud Avatar answered Sep 20 '22 16:09

gnud