Problems with spaces in paths when calling a batch file from R

前端 未结 2 1196
耶瑟儿~
耶瑟儿~ 2021-01-22 14:46

I have some problems to call a command line program called molconvert from R using system() in Windows. molconvert is located in \"C:\\Program Files\\ChemAxon

相关标签:
2条回答
  • 2021-01-22 14:57

    the easiest way to fix this is to use short paths:

    for %%a in ("C:\molecule conversions\cembrene A.mol") set "sh_path=%%~dpfnxsa"
    

    or

    for %%a in ("C:\Program Files\ChemAxon\MarvinBeans\bin") do set "pf_sh_path=%%~dpfnxsa"
    

    and then to pass %sh_path% and %pf_sh_path% as parameter.

    0 讨论(0)
  • 2021-01-22 15:11

    You want to use shQuote to quote the path to the executable, not the entire command line. Depending on what your molconvert program expects, you may also want to quote paths that are arguments to it.

    system(paste(shQuote(file.path(dirmolconvert, "molconvert.exe")),
                 "pdb",
                 shQuote("C:\\molecule conversions\\cembrene A.mol"))
    
    0 讨论(0)
提交回复
热议问题