ID 390589 - Writing an image-based file using the filenameFix function to cross platform file paths, will create an error when rendering a Mac/Linux path on a Windows machine

Follow

Problem summary
When Writing an image-based file using the filenameFix function (as per the below article), if you render using a pathed Mac/Linux location within Windows, you will get an error stating, 'no backslashes allowed in filename'.
https://learn.foundry.com/nuke/11.3/content/comp_environment/configuring_nuke/file_paths_cross_platform.html

This only occurs in Windows and does not occur with either exr or mov files.

Customer reported version
nuke.11.3v3

Customer reported platform

Steps to reproduce

1) Based upon the article above, amend the following code into your init.py file within your .nuke directory (if you do not have an init.py file, create one a text editor)
import platform

def filenameFix(filename):
  if platform.system() in ("Windows", "Microsoft"):
      return filename.replace( "/SharedDisk/", "P:\\" )
  return filename.replace( "P:\\", "/SharedDisk/" )

2) Before saving, replace the P:\\ location with either a usable drive location on your Windows machine or a server location.
for example: E:\\

3) Within Windows, copy an image file into a new folder within the Windows location you specified above.
for example: E:\\NewFolder\Image.####.jpg

4) Open a new Nuke session and Read in the above image location

5) Within the Read file input, change the E:// drive to the cross platform drive /SharedDisk/ 
for example: /SharedDisk/NewFolder/Image.####.jpg

6) Select Reload, to reload the image and use the init.py snippet to replace the directories automatically.
Note: You will know if this works correctly if the image does not error.

7) Create a Write node and render as a dpx file to the Read folder location.
for example: /SharedDisk/NewFolder/Image.####.dpx

Result: You will receive the following error message
 ​


8) Render as an mov or exr file

Result: No error

Expected behaviour
Image-based files being rendered should not encounter an error over cross platform pathing using the filenameFix function

Actual behaviour
Image-based files being rendered encounter an error over cross platform pathing using the filenameFix function

Workaround
Our suggested alternative is to alter the cross platform pathing via the Path Substitutions options in the Preferences > General tab

An example using our above workflow would be the following:
​​
​​

If you have no need to do this through the init.py method, we suggest doing it through the Path Substitutions method, where the error will not occur on rendering image-based files.

Reproduced by support
This bug has been reproduced in:
Nuke 11.3v3 - Windows 7 - Centos 7 - MacOS 10.13.2
Nuke 11.3v1 - Windows 7
Nuke 11.2v5 - Windows 7
Nuke 11.2v1 - Windows 7
Nuke 11.1v1 - Windows 7
Nuke 11.0v1 - Windows 7
Nuke 10.5v1 - Windows 7
Nuke 10.0v1 - Windows 7
Nuke 9.0v1 - Windows 7
Nuke 8.0v1 - Windows 7 - Centos 7 - MacOS 10.13.2

Earliest version tested
Nuke 8.0v1
- This issue appears to be in all versions of the product

    We're sorry to hear that

    Please tell us why