# Path manipulation: combine path with filename

**URL:** https://www.finalbuilder.com/forums/t/path-manipulation-combine-path-with-filename/3874
**Category:** Feature Requests
**Created:** [August 1, 2007, 7:26am UTC](https://www.finalbuilder.com/forums/t/path-manipulation-combine-path-with-filename/3874 "2007-08-01T07:26:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stevage](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@stevage](https://www.finalbuilder.com/forums/u/stevage)
#### Post date: [August 1, 2007, 7:26am UTC](https://www.finalbuilder.com/forums/t/path-manipulation-combine-path-with-filename/3874/1 "2007-08-01T07:26:01Z")

</div>

Relatively often I have to perform the following operation: Given filename F, add path P, but only if F doesn't already contain a path. So:

F: file.txt

P: c:\foo

Result: c:\foo\file.txt

F: c:\bloo\file.txt

P: c:\foo

Result: c:\bloo\file.txt

&nbsp;

It's relatively awkward to do this succinctly: I use an if/else with a regular expression. A single operation to do it (perhaps by extending path manipulation even further) would be handy. Perhaps with a flag allowing the provided path to always override any given path.

Steve

---

<div class="post-metadata">

### Author: ![pqsystems](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/ec9cab/32.png) [@pqsystems](https://www.finalbuilder.com/forums/u/pqsystems)
#### Post date: [September 14, 2010, 12:49pm UTC](https://www.finalbuilder.com/forums/t/path-manipulation-combine-path-with-filename/3874/2 "2010-09-14T12:49:33Z")

</div>

I would also like to see a general path combine operation.   
  
 For example:   
 Combine(C:\Temp, \myfile.txt) = C:\Temp\myfile.txt   
 Combine(C:\Temp, \myfile.txt) = C:\Temp\myfile.txt   
 Combine(C:\Temp, myfile.txt) = C:\Temp\myfile.txt   
 Combine(C:\Temp, myfile.txt) = C:\Temp\myfile.txt   
 Combine(, \myfile.txt) = myfile.txt   
 Combine(, myfile.txt) = \myfile.txt
