algorithmic modeling for Rhino

Copy/Move files in a directory (with filter name) to another directory

I wondering if someone could help me with this little question:

I would like to copy or move all files in a subdirectory (eg: like DirMain>Dir1, Dir2,...,DirN), i mean all files in each Dir1, Dir2,...,DirN that their name matches to a filter name var (eg: if file name contains some letter or number.. like *ABC*123*.txt) and move only these files to another directory with different name (it depends on filter name).

PS. GH component with some input, eg. path list of files and panel text as list of filter name.

I hope I was clear about this little question. Thank you in advance :)

Views: 1539

Replies to This Discussion

The attached file has two C# components, one which finds all files in a (sub)directory structure that match a certain name pattern, the other moves existing files to new locations.


Thank you so much David! As always thanks for your help and effort in GH development! Now i've a base to work on adapting the script for more specific needs. 

Could you tell me some information about a quick reference texts in order to operate with the components (i mean c++/c# and/or python)? Often i surfed on internet (eg: etc..) to find some specific code to implement my components...clearly mine is just a curiosity.

Essential C# is supposed to be good, but I've never read it. These days my questions are so specific that searching the web is the most efficient way to find something. For basic questions about a specific class or method MSDN is my go-to resource, after that it's Google which leads me to StackOverflow 9 times out of 10.

In my script btw. I'm using a more complicated way to delete the old files because I wanted them to end up in the Windows recycle bin (it's always safer this way if you're deleting files you might want back). You could however switch to just using System.IO.File.XXXX() methods entirely and that would be easier to write.

Thanks! Very useful!

I need similar functionality from the "find file" c# component David shared. 

I need it to return the paths in a grasshopper friendly way while returning also empty folders.

Main Folder1/item1.txt{0}

Main Folder1/Sub folder1/item1.txt {0;0}

Main Folder1/Sub folder2/item1.txt {0;1}

Main Folder1/Sub folder3/=Empty={0;2}

Main Folder2/Sub folder2/item1.txt {1;1}

Main Folder1/Sub folder2/SubSub folder 1/item1.txt {0;1;0}

Any Idea how to do this recursively for all the sub directories within the supplied directory.






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2021   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service