# Iterate parts of string (path) / String Split

**URL:** https://www.finalbuilder.com/forums/t/iterate-parts-of-string-path-string-split/515
**Category:** Discussion
**Created:** [June 28, 2007, 6:08am UTC](https://www.finalbuilder.com/forums/t/iterate-parts-of-string-path-string-split/515 "2007-06-28T06:08:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 28, 2007, 6:08am UTC](https://www.finalbuilder.com/forums/t/iterate-parts-of-string-path-string-split/515/1 "2007-06-28T06:08:59Z")

</div>

Hi, I want to make a tag in SVN, hence create&nbsp;none or&nbsp;several&nbsp;directories using the SVN MkDir action.

The starting point is a string with the destination path in SVN:  
"svn://c++/tags/project/version/project"

So logically I need to create the following directories (I know "c++/tags" exists):  
1. "svn://c++/tags/project"  
2. "svn://c++/tags/project/version"  
3. "svn://c++/tags/project/version/project"

The challenge is to find and easy way to iterate the different folders (or put&nbsp;sub folders&nbsp;onto a stack variable). I can not find any easy way of extracting the folders from the string containing the full path.

I was looking for a "String Split"&nbsp;action that could create a stack/queue/list that I could iterate, but failed to&nbsp;find any suitable actions to solve my challenge...

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [July 4, 2007, 2:52am UTC](https://www.finalbuilder.com/forums/t/iterate-parts-of-string-path-string-split/515/2 "2007-07-04T02:52:07Z")

</div>

Hi Eirik,   
  
 Sorry for the delay in getting back to you.   
  
 This is quite a hard problem, and there’s no “out of the box” FB solution for it. What I would do is something like this:   
  
 1) Suppose the destination path in SVN is stored in FinalBuilder project variable called SVNPath.   
  
 2) Create three new FinalBuilder project variables called (say) PathSegments, RebuildPath and Segment.   
  
 3) Use a Run Script action to split the SVNPath up into sections, something like this:   
  
 (Script language type = JScript, use the OnExecute event on the Script Editor tab for the Run Script action)   
  
 var temp = SVNPath.split(’/’); // Create an array from the elements of the path   
 RebuildPath = temp.shift(); // First segment is the “svn://c++” part of the path. Shift it out of the array   
 PathSegments = temp.join(’\r\n’);   
  
 4) Add a List Iterator action after the Run Script action. Set the content to %PathSegments% and the ‘variable to set’ to Segment.   
  
 5) Add the SVN MkDir action as the child of the List Iterator   
  
 6) In the SVN Action’s BeforeAction script event, put the following JScript:   
  
 RebuildPath = RebuildPath + ‘/’ + Segment   
  
 7) Configure the SVN action to use RebuildPath as the path to recreate.   
  
  
 … this is pretty tricky, and I haven’t actually tested it myself. Let me know if you’d like me to mock up a demonstration project instead.   
  
 Regards,   
  
 Angus
