r/learnpython • u/westnile609 • Jun 05 '21
Running Terminal Commands With Python
I was wondering if there is a way to run terminal commands(ios) with python. Looking to change file names and other tasks that can be done in terminal ie "mv ~/Desktop/MyFile.rtf ~/Desktop/MyFile-old.rtf". Let me know!
1
Upvotes
View all comments
1
u/TabulateJarl8 TabulateJarl8 - GitHub & GitLab Jun 05 '21
There is a way to run terminal commands in python with the os and subprocess modules, but try to avoid it as much as possible, and try to use built in things. You can rename files in Python with
os.rename()(or you can just move the file to the new name with a different built in function)