简体   繁体   中英

Batch script stops after output conda environment

I'm trying to write a batch script to export all available conda evnironments, after searching piece by piece on the internet, I came up with the following:

@echo off

conda info --envs > conda_envs.txt

for /f "usebackq tokens=1 delims= " %%a in ("conda_envs.txt") do (
    if not %%a==# conda env export -n %%a > %%a.yml
)

The problem is that the script stops after conda info --envs > conda_envs.txt , I've tried to add call in front of both the for loop and export command, but no luck. What did I do wrong?

Many thanks to npocmaka , michael_heath and SomethingDark in the comment section, I think the missing parentheses made the debug process harder. By adding call in front of conda does help! Below is a working version of the script:

@echo off

call conda info --envs > conda_envs.txt

for /f "usebackq tokens=1 delims= " %%a in ("conda_envs.txt") do (
    if not %%a==# call conda env export -n %%a > %%a.yml
)

PS: if the second call before conda env export... is not added, this would work as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM