# path filters for windows

**URL:** <https://forum.ansible.com/t/path-filters-for-windows/18954>\
**Category:** Ansible Developer\
**Tags:** windows\
**Created:** [August 5, 2015, 4:39pm UTC](https://forum.ansible.com/t/path-filters-for-windows/18954 "2015-08-05T16:39:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 5, 2015, 4:39pm UTC](https://forum.ansible.com/t/path-filters-for-windows/18954/1 "2015-08-05T16:39:55Z")

</div>

Anyone have any objection to me adding a few filters for windows paths?

looks pretty straightforward to do, just import ntpath then use the ntpath versions of the os.path methods:

I’m thinking just add the following (and using the ansible-ish convention of starting windows things with win\_):

‘win\_basename’: partial(unicode\_wrap, ntpath.basename),  
‘win\_dirname’: partial(unicode\_wrap, ntpath.dirname),  
‘win\_expanduser’: partial(unicode\_wrap, ntpath.expanduser),

Jon

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 5, 2015, 5:20pm UTC](https://forum.ansible.com/t/path-filters-for-windows/18954/2 "2015-08-05T17:20:42Z")

</div>

Actually win\_expanduser would be no use, since the filter would be run on the ansible controller only.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 5, 2015, 5:54pm UTC](https://forum.ansible.com/t/path-filters-for-windows/18954/3 "2015-08-05T17:54:01Z")

</div>

Well its here if anyone would like it:

[https://github.com/ansible/ansible/pull/11864](https://github.com/ansible/ansible/pull/11864)

cheers,

Jon
