我有三个单独的.bat文件。每个命令分别具有以下三个命令。
file1.bat: cmd /K "cd C:\PythonScripts\X3865\ & python run_all.py"
file1.bat: cmd /K "cd C:\PythonScripts\X3865_1\ & python run_all.py"
file1.bat: cmd /K "cd C:\PythonScripts\X3865_2\ & python run_all.py"
目前要执行该程序,我转到Windows文件夹并双击它们以启动程序。它们出现在三个不同的命令窗口中。
我想将上述命令合并到一个单独的.bat文件中,该文件在执行时会自动启动所有三个程序。我怎么能这样做?
答案 0 :(得分:0)
这应该按顺序运行Python脚本:
python "C:\PythonScripts\X3865\run_all.py"
python "C:\PythonScripts\X3865_1\run_all.py"
python "C:\PythonScripts\X3865_2\run_all.py"
他们的输出将全部打印到同一个cmd窗口。如果您希望最后看到输出,请将pause
添加到bat文件的末尾,以便它不会自动关闭。
答案 1 :(得分:0)
将以下内容保存到Files
.walk(Paths.get("YOUR_PATH"))
.map(Path::toFile) // convert Paths to Files
.filter(File::isFile) // filter to remove directories
.map(File::toString) // convert files to Strings
.collect(Collectors.toList()); // to return a list of Strings
文件
.bat
然后只运行python "C:\PythonScripts\X3865\run_all.py"
python "C:\PythonScripts\X3865_1\run_all.py"
python "C:\PythonScripts\X3865_2\run_all.py"
文件就可以了。
答案 2 :(得分:0)
来自 Mark 和 ian0411 的答案将依次运行三个python脚本。如果这就是你想要的,那就选择其中任何一个。如果要同时运行三个脚本,则批处理文件应为
start cmd /c python "c:\pythonscripts\x3865\run_all.py"
start cmd /c python "c:\pythonscripts\x3865_1\run_all.py"
start cmd /c python "c:\pythonscripts\x3865_2\run_all.py"
这将在一个单独的窗口中开始;如果命令中需要输出,请将/c
更改为/k
;这将使窗口保持打开状态,直到您手动关闭它。