# Escape space in Windows directory path in playbook

**URL:** <https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 2, 2016, 3:52pm UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943 "2016-11-02T15:52:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://forum.ansible.com/u/Tim3)\
**Post date:** [November 2, 2016, 3:52pm UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943/1 "2016-11-02T15:52:13Z")

</div>

Hi,

I want to copy some files to the Startup folder using “win\_copy”. The problem is, that the destination directory is  
“dest=C:/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp/link.lnk” which has a space between “Start” and “Menu”.  
I tried to escape that with quotation marks, but that didn’t work. Is there another way to escape space?

Thanks,  
Tim

---

<div class="post-metadata">

**Author:** ![cupcake](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@cupcake](https://forum.ansible.com/u/cupcake)\
**Post date:** [November 2, 2016, 7:33pm UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943/2 "2016-11-02T19:33:32Z")

</div>

First check your version of Ansible as some older version may have had some bugs with spaces in paths.

I’d think you need to quote around the path itself. using strict yaml i think ive done it

dest: ‘C:\Documents and Settings\All Users\Start Menu\Windows Update.lnk’

or if you go with doublequotes, i think you may need doublslashes like

dest: “C:\Documents and Settings\All Users\Start Menu\Windows Update.lnk’”

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [November 3, 2016, 10:16am UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943/3 "2016-11-03T10:16:05Z")

</div>

Alternatively use 8.3 DOS Format as the path.

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [November 3, 2016, 3:26pm UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943/4 "2016-11-03T15:26:26Z")

</div>

Stick to YAML syntax instead of Ansible key=value syntax and you don’t have to quote or escape at all:

- win\_copy  
src: somelocalfile.bin  
dest: c:\windows\somelocalfile.bin

If you’re in a situation where you need to quote, YAML single-quotes are also escape-free. Double-quoting allows escape characters, which means you’ll either need to double your backslashes or switch to forward slashes (_most_ modules are OK with this, but there are a handful that fix the paths up correctly).

-Matt

---

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://forum.ansible.com/u/Tim3)\
**Post date:** [November 9, 2016, 4:45pm UTC](https://forum.ansible.com/t/escape-space-in-windows-directory-path-in-playbook/22943/5 "2016-11-09T16:45:21Z")

</div>

Thanks, your solution worked. I changed the key/value syntax to the YAML syntax like you did in your example.
