1

I have a default folder called \normal however python detects the \n same with if i put extracted \" I keep getting permission denied writing and assuming it is because of the missing \

\"folder_normal = "F:\Extractor\normal" folder_output = "F:\Extractor\Extracted\"

Edit

With the \ \ or the r it changes the folder to F:\\Extractor\\Extracted\\\\ what even with os.mkdir cannot find the folder

3 Answers3

2

use raw format

folder = r"F:\Extractor\normal"

It's the best way to write paths because you don't need to worry about possible changes where you will miss another \a \b \n \t \v sign.

Alternatively you can use "/" instead of "\".

See: https://community.esri.com/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python to find other solutions

muminers
  • 1,190
  • 10
  • 19
0

input an additional \

folder_normal = "F:\Extractor\\normal"
folder_output = "F:\Extractor\Extracted\"
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Steven Black
  • 1,988
  • 1
  • 15
  • 25
  • you only need the two when they're followed by a `n` or a `t`, as these are special characters that need to be "escaped" (a newline and a tab, respectively) – Steven Black Mar 30 '18 at 13:51
  • 1
    You need two when they're followed by `n` or `t` or `a` or `b` or `f` or `r` or `v` or `x` or a number. The smart solution is to use a raw string literal instead of doubling your backslashes. – Aran-Fey Mar 30 '18 at 13:54
  • @Aran-Fey: or a `u`, or any other possible future extension to Python's GREP. You're right, this is not a good solution at all; no more than an ad hoc fix. – Jongware Mar 30 '18 at 14:07
0

When I write Python in windows and have to deal with paths, I simply use forward slashes instead of back slashes. Sure, you can do proper escaping but it always turns into a hassle of errors it seems. So, change all your

\

to

/

So in this case, write this:

folder_output = "F:/Extractor/Extracted/"

And you should be good to go!

sniperd
  • 5,124
  • 6
  • 28
  • 44