Building a string is easy, but building a
Cmd is always a headache to me. So I write a small package to run strings as
Here is the task that drives me to write the package: There are some sub-folders containing
.png files. I want to convert them into videos and place these videos at the root folder. And here is the code
julia> using Shell julia> for (r,d,f) in walkdir(".") if any(x->endswith(x, ".png"), f) run("convert $r/*.png $(basename(r)).mp4") end end
It is more intuitive than dealing
Cmd objects (In fact, I still not able to write the correct
Cmd for this task…). Hope this will help someone.
It also supports windows.
julia> using Shell julia> run("dir") ... (some output) julia> useshell("powershell") "powershell" julia> run("ls") ... (some output)
@yuyichao pointed out below, there are something wrong with the code. And I quote it here
- The package is doing type piracy, don’t extend Base.run.
- Please put a warning in the README to that people are NOT encouraged to write buggy code as what you show above.