I have the directory, where I have to store all the items separately in the list of folders. This list includes exactly the same folders only with incrementing number, as you can see below:
Because I am going to have more than 200 folders, I decided to create all of them by using Python console in QGIS.
My approach so far looks as you can see below:
import os
path='C:\\Users\\mk\\Desktop\\AX\\Pre survey\\Tyton'
os.chdir(path)
for i in range (1,208):
Newfolder='Strand-' + str(i)
os.makedirs(Newfolder)
As per the tutorial below:
https://www.youtube.com/watch?v=4nr0eW3w1u4&ab_channel=PyBTV
Since I managed to create one folder, there is a problem with the batch of these folders.
First of all, I cannot put something like "leading 0", as I tried:
for i in range (001,208)
I cannot do this, but I need the folder numeration as shown in the image.
Another issue is, that if I use the whole code presented, Python throws an error:
IndentationError: expected an indented block
debugging the following line:
Newfolder='Strand-' + str(i)
The examples how to solve this error are here:
but i couldn't apply them to my situation.
How can I do the batch directory creation with Python, preferably by QGIS python console?