Hi there, aspiring programmer and total Nim-Noob is asking for your wisdom. In 
order to dive deeper in to the adventure that programming is I decided to have 
a go on Nim. Thought it would be a good idea to re implement s.the. I already 
did in Bash, just to have the logic out of the way. Now this project involves 
indexing large parts of / and ~ but I want to leave out logs, cashes and some 
other stuff.

Given following dir-structure, 
    
    
    .__ file_a
    |
    |__folder_1
    |     |__file_1.a
    |     |__file_1.b
    |
    |__folder_2
           |__file_2.a
           |__file_2.b
    
    
    Run

I tried the following: 
    
    
    import os, re
    
    for file in walkDirRec ".":
      if file.match (re"\S*folder_1\S*"):
        echo "NO!"
        continue
      echo file
    
    
    
    Run

this would output: 
    
    
    ./file_a
    NO!
    NO!
    ./folder_2/file_2.a
    ./folder_2/file_2.b
    
    
    Run

Now I can achieve my goal with that and e.g. write only the paths I want to a 
file or something. But there are two things bugging me about this: First: In 
Bash, I used find to pipe the paths into a file. With the prune flag I could 
stop find from descending into those directories completely and therefore save 
quite a bit of time. The above method would iterate over every single file 
anyway. Second: I'd prefer to have an array where the folders to be excluded 
are stored. As strings maybe? (I played a bit with Python and their os.walk can 
do that). But my attempts to get this working based on string comparison were 
futile, to say the least.

Now I know that as a newcomer to programming I might very well be of on a 
completely wrong track and I have to tackle things in another way to begin 
with. But it somehow stumps me, that I was able to figure this out in two other 
languages and am so lost here in Nim. I guess the easy to pick up part is more 
in the syntactic part than the approach?

Anyway, any little bit of guidance, regardless of direction, would be much 
appreciated. Greetings, Markus

Reply via email to