Create new folder on the server


i create a app for the propose to print the label, meanwhile i will system.print.printToImage to print the screen on my server, the server address is \192.168.17.9\Pictures\CureSheetPhoto\WareHouse\20200713141500.jpg
due to everyday will have many pictures, i want to everyday to create a new folder
i see the previous topic relate to this request:

i will success create a new folder on my computer’s desk
but if i want to create them on the server, i will not able to see new folder, but if i want to try again, it will report fault that file alread exists.



how to create a folder on the server?

When using backslashes to address a filepath, you’ll have to use another backslash to escape the backslash. So your example would change to:

import os, sys
DesPath="D:\\Payout2\\Jul 39"
DesPath2="\\\\192.168.17.9\\Pictures\\CureSheetPhoto\\WareHouse\\Jul29"
if (not os.path.exists(DesPath)):
	os.makedirs(DesPath)
if (not os.path.exists(DesPath2)):
	os.makedirs(DesPath2)

Edit: Changed the DesPath2 to correct the slashes prior to the IP

2 Likes

I think DesPath2 should look like this:

DesPath2="\\\\192.168.17.9\\Pictures\\CureSheetPhoto\\WareHouse\\Jul29"
1 Like

You’re right, thank you for the correction. I’ve corrected it above.

1 Like