# addpath("C:\\Users\\")

**URL:** <https://discourse.julialang.org/t/addpath-c-users/22519>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [March 29, 2019, 9:59pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519 "2019-03-29T21:59:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aquaman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaman/32/6586_2.png) [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Post date:** [March 29, 2019, 9:59pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/1 "2019-03-29T21:59:49Z")

</div>

Dear All,

how can we include files from a folder : **addpath("C:\Users")** in Julia 1.1.0. As far as I know about include(“abc.jl”)

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [March 29, 2019, 10:23pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/2 "2019-03-29T22:23:49Z")

</div>

Is this something you are looking for?

```julia
cd(raw"C:\Users") do
    foreach(include, filter!(x -> isfile(x) && endswith(x, ".jl"), readdir()))
end

```

---

<div class="post-metadata">

**Author:** ![Aquaman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaman/32/6586_2.png) [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Post date:** [March 29, 2019, 10:26pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/3 "2019-03-29T22:26:35Z")

</div>

Hi bkamins,

do we have other choices in Julia (e.g. less commands?)?

Thanks!🙂

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [March 29, 2019, 10:40pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/4 "2019-03-29T22:40:58Z")

</div>

You can define a function that does that and then call it. Note, there’s no need to `cd` into a directory to read it’s contents:

```julia
function include_all_files(dir::String)
    files = filter!(x -> isfile(x) && endswith(x, ".jl"), readdir(dir)
    foreach(include, files)
end

```

Why do you want to include all the files in a directory in the first place?

---

<div class="post-metadata">

**Author:** ![Aquaman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaman/32/6586_2.png) [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Post date:** [March 29, 2019, 11:01pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/5 "2019-03-29T23:01:16Z")

</div>

I want to call many functions (.jl files) in Julia from the same folder, addpath(‘\sdada’) perhaps is the simplest way? or?

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [March 29, 2019, 11:15pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/6 "2019-03-29T23:15:42Z")

</div>

> [@StefanKarpinski](#):
>
> Note, there’s no need to `cd` into a directory to read it’s contents:

You have to change the directory because `readdir` returns names relative to the passed directory (so `include` later will not work if you are not in the right directory).

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 29, 2019, 11:56pm UTC](https://discourse.julialang.org/t/addpath-c-users/22519/7 "2019-03-29T23:56:34Z")

</div>

As I know you’re transitioning from MATLAB I thought I’d might be good to point out that in Julia you don’t need to define functions in separate files or by one (I recall doing this with m files circa 2014). So if you’re looking for this to replicate a MATLAB style codebase with lots of tiny files containing function definitions, don’t!

---

<div class="post-metadata">

**Author:** ![Aquaman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaman/32/6586_2.png) [@Aquaman](https://discourse.julialang.org/u/Aquaman)\
**Post date:** [March 30, 2019, 12:01am UTC](https://discourse.julialang.org/t/addpath-c-users/22519/8 "2019-03-30T00:01:28Z")

</div>

Sure,if I want to use e.g. The MATLAB tensor toolbox ([https://www.sandia.gov/~tgkolda/TensorToolbox/index-1.0.html](https://www.sandia.gov/~tgkolda/TensorToolbox/index-1.0.html)) in Julia, I have no idea how to use it directly in Julia, therefore, I have to translate it from matlab to julia, file by file, line by line, …

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 30, 2019, 12:05am UTC](https://discourse.julialang.org/t/addpath-c-users/22519/9 "2019-03-30T00:05:47Z")

</div>

What I was trying to say was you don’t have to do it like by line necessarily, but can just define all the functions in one file and include that (rather than having to include all files in a folder). I seem to remember that MATLAB has weird restrictions on how functions need to be defined so wanted to point out that Julia doesn’t have these.

I haven’t looked at what you’re trying to translate though, so wouldn’t want to comment on what the best way to organise the code is.
