0

Please find my python script below:

import os;
import sys;

dir_dst = sys.argv[1]

for x in range(150) :
    dirname = str(x)
    dst_dir = os.path.join(dir_dst, dirname)
    dirname = "annotation"
    dst = os.path.join(dst_dir, dirname)
    print dst
    if not os.path.exists(dst_dir):
        os.mkdir(dst)

The aim is to create a directory called "annotation" within each of the numbered directories ranging as in the code above. This code doesn't do it and on printing the value of "dst", here's an example of what it shows:

NLP/test data/reconcile/0\annotation
NLP/test data/reconcile/1\annotation

How can this be resolved?

1
  • no need to use ; after the import statement Commented Jan 8, 2012 at 22:45

1 Answer 1

4

Change the second to last line to

if not os.path.exists(dst):

Right now you're checking if the original directory exists.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.