python 文件批处理,如何创建批处理文件以运行同一目录中的所有python文件

I have a folder where I keep my python scripts used for backing up a particular system.

Z:\System Administrator\System Backups\My System\Scripts\

To start them all going I would like to use a .bat file kept in the same folder, however I have zero experience with these files. My reading has lead me to this solution :

@echo off

start /B python "File one.py"

start /B python "It's another file.py"

And if I list every python file in this way then it works as I would want. How can I run all *.py files that appear in this folder regardless of number or filename ?

Thanks in advance

解决方案

That's possible with the following trick:

@echo off

for %%A IN (*.py) do start /b /wait "" python "%%~fA"

Note: For older Windows versions (pre Windows 10) the order is specific. , See here.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值