0

I would like to export all my conda libraries in one go.

So the question was partly answered in this post: Export all created conda environments

for env in $(conda env list | cut -d" " -f1); do 
   if [[ ${env:0:1} == "#" ]] ; then continue; fi;
   conda env export -n $env > ${env}.yml
done

but since i'm not so experienced, or perhaps plain stupid, my question is: ** where and how do I run this piece of code on a win10 machine?**

running it in conda doesn't work, cmd prompt also fails screenshot

do I need to put it in a script? Or is this solution simply not going to work on windows?

merv
  • 67,214
  • 13
  • 180
  • 245
Ritchie
  • 1
  • 1
  • 1
    This is bash code. You either need to run bash shell (e.g., GitBash) or convert it to a Windows-specific version (e.g., Batch or PowerShell). – merv May 08 '23 at 19:43

1 Answers1

0

Found a solution:

  1. put the script in a notepad file
  2. rename the extention to .bat
  3. run it from windows explorer

improved on the script as following:

@echo off

for /f "tokens=*" %%a in ('conda env list ^| findstr /r /c:"^[^#]" ^| findstr /v /r /c:"^base" ^| %__APPDIR__%more.com +1') do (
    echo %%a
    call :export_env "%%a"
)

pause
goto :eof

:export_env
setlocal
set input_string=%~1
for /f "tokens=1,2 delims= " %%a in ("%input_string%") do (
    set env_name=%%a
    set path1=%%b
)
conda env export -n %env_name% > %env_name%.yml
echo %env_name%.yml
endlocal
Ritchie
  • 1
  • 1