unpacking rar with R system()

我怕爱的太早我们不能终老 提交于 2019-12-05 20:53:52

Ok, I finally got it.

  1. Use shell
  2. Use shQuote for surrounding path
  3. Use right keys

    z7path = shQuote('C:\\Program Files (x86)\\7-Zip\\7z')
    file = paste(getwd(), '/101-01.rar', sep = '')
    cmd = paste(z7path, ' e ', file, ' -y -o', getwd(), '/', sep='')
    shell(cmd)
    

I had to modify the code from the second answer, and finally it works. You can change "-ir!. -o" by "-y -o" if you want all files.

z7path = shQuote('C:\\Program Files\\7-Zip\\7z')
file = paste('"', 'D:/20140601.rar', '"',sep = '')
cmd = paste(z7path, ' e ', file, ' -ir!*.* -o', '"', getwd(), '"', sep='')

system(cmd)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!