I am using Windows 10 Enterprise + Julia 1.1 + 7-zip (2019-02-21) 64 bits
cc = `7z a c:\\temp\\f1.zip c:\\temp\\f1.txt`
run(cc)
IOError: could not spawn 7z a 'c:\temp\f1.zip' 'c:\temp\f1.txt': no such file or directory (ENOENT)
_spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at process.jl:400
setup_stdios(::getfield(Base, Symbol(“##505#506”)){Cmd}, ::Array{Any,1}) at process.jl:413
_spawn at process.jl:412 [inlined] run#515(::Bool, ::Function, ::Cmd) at process.jl:725
run(::Cmd) at process.jl:724
top-level scope at none:0
Then I open a windows terminal
Without Single Quote, it works:
Adding Single Quote, it failed, exactly the same as Julia 's case
In a windows command line, you try to add Single Quote to your file name, does it still work?
i.e. you will run this in windows command line, not Julia REPL:
7z a 'E:\\Downloads\\foo.zip' 'E:\\Downloads\\foo'
If you upgrade you 7 zip to v19 or latest 2019-02 version, with 64-bit, does it still work?
Those are different errors. I’m pretty sure Julia can’t find 7z for some reason, so try specifying the complete path (e.g. as joinpath(Sys.BINDIR, "7z") if you want to use the 7zip shipped with Julia).
If I past the command string (line 2 of the code snippet) - without the backticks and WITHOUT the single apostrophes of the first argument - into a cmd.exe window; things work perfectly
julia> cmd = Cmd(`rename $(fi) $(fnonlyNew)`,windows_verbatim=true)
`rename 'C:\temp\abc.jpg' 2020-10-06T132158_abc.jpg`
julia> run(cmd)
ERROR: IOError: could not spawn `rename 'C:\temp\abc.jpg' 2020-10-06T132158_abc.jpg`: no such file or directory (ENOENT)
Stacktrace:
[1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:99
[2] #585 at .\process.jl:112 [inlined]
[3] setup_stdios(::Base.var"#585#586"{Cmd}, ::Array{Any,1}) at .\process.jl:196
[4] _spawn at .\process.jl:111 [inlined]
[5] run(::Cmd; wait::Bool) at .\process.jl:439
[6] run(::Cmd) at .\process.jl:438
[7] top-level scope at REPL[113]:1
[8] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088
Julia isn’t running a shell, so things like > won’t work out of the box. You can either use pipeline to redirect stdout/in/err or just run your whole command in a shell with e.g.