Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursively create a file
#13
Ok, now that my grammar nazi attitude towards python is fixed, I'm still not getting any output file in the folders.
I don't get any debug error but simply nothing happens.

I tried different ways, specifing folders paths, different way to implement open, as well as different scripts in order to see if the open file makes something but no joy. Is it because the script is trying to write a file at the same time it write the folder?



EDIT: see top or bottom part of the script.


#!/usr/bin/python

print 'Running OKAYfolder script. This script will generate the standard tree structure for OKAYstudio scripts (projects)'

while True:
    import os
    aw_directory = "/mnt/sdb1/_Active Working/9999_testfolder"
    for child in os.listdir(aw_directory):
        project_path = os.path.join(aw_directory, child)
        if os.path.isdir(project_path):
#    DATALAB BRANCH
        a     = os.path.join(project_path, '001_DATALAB')
        open('file.txt', 'w').close()
        b    = os.path.join(project_path, '001_DATALAB/001_Rushes')
        c    = os.path.join(project_path, '001_DATALAB/001_Rushes/001_video')
        d    = os.path.join(project_path, '001_DATALAB/001_Rushes/002_audio')
                e    = os.path.join(project_path, '001_DATALAB/002_Transcodes')
                f    = os.path.join(project_path, '001_DATALAB/003_Encodes')
                g    = os.path.join(project_path, '001_DATALAB/004_Artwork-Titles-Graphics')
                h    = os.path.join(project_path, '001_DATALAB/005_Music-Sound')
#       EDITORIAL BRANCH
        i    = os.path.join(project_path,'002_EDITORIAL')
        j    = os.path.join(project_path,'002_EDITORIAL/001_offline/')
        k    = os.path.join(project_path,'002_EDITORIAL/001_offline/001_exports')
        l    = os.path.join(project_path,'002_EDITORIAL/001_offline/002_assets')
        m    = os.path.join(project_path,'002_EDITORIAL/002_online')
        n    = os.path.join(project_path,'002_EDITORIAL/002_online/001_exports')
        o    = os.path.join(project_path,'002_EDITORIAL/002_online/002_assets')
#       ANIMATION BRANCH
        p    = os.path.join(project_path,'003_ANIMATION')    
        q    = os.path.join(project_path,'003_ANIMATION/001_exports')
        r    = os.path.join(project_path,'003_ANIMATION/002_assets')
#       GRADE BRANCH
        s    = os.path.join(project_path,'004_GRADE')
        t    = os.path.join(project_path,'004_GRADE/001_exports')
        u    = os.path.join(project_path,'004_GRADE/002_assets')
#       VFX BRANCH
        v    = os.path.join(project_path,'005_VFX')
        w    = os.path.join(project_path,'005_VFX/001_exports')
        x    = os.path.join(project_path,'005_VFX/002_assets')
#       REF&TREATMENTS BRANCH
        y    = os.path.join(project_path,'006_REF-TREATMENTS')
#       DELIVERABLES BRANCH
        z    = os.path.join(project_path,'007_DELIVERABLES')
        aa    = os.path.join(project_path,'007_DELIVERABLES/001_WIP')
        ab    = os.path.join(project_path,'007_DELIVERABLES/001_WIP/001_offline')
        ac    = os.path.join(project_path,'007_DELIVERABLES/001_WIP/002_animation')
        ad    = os.path.join(project_path,'007_DELIVERABLES/001_WIP/003_grade')
        ae    = os.path.join(project_path,'007_DELIVERABLES/001_WIP/004_VFX')
        af    = os.path.join(project_path,'007_DELIVERABLES/001_WIP/005_online')
        ag    = os.path.join(project_path,'007_DELIVERABLES/002_Master')
        ah    = os.path.join(project_path,'007_DELIVERABLES/002_Master/encodes')

#       DATALAB VARIABLES
        if not os.path.exists(a):
            original_umask_a = os.umask(0)            
            os.makedirs(a, mode=0777)
            os.umask(original_umask_a)
                if not os.path.exists(b):
                    original_umask_b = os.umask(0)
                    os.makedirs(b, mode=0777)
                    os.umask(original_umask_b)
                if not os.path.exists(c):
                    original_umask_c = os.umask(0)
                    os.makedirs(c, mode=0777)
                    os.umask(original_umask_c)
                if not os.path.exists(d):
                    original_umask_d = os.umask(0)
                    os.makedirs(d, mode=0777)
                    os.umask(original_umask_d)
                if not os.path.exists(e):
                    original_umask_e = os.umask(0)
                    os.makedirs(e, mode=0777)
                    os.umask(original_umask_e)
                if not os.path.exists(f):
                    original_umask_f = os.umask(0)
                    os.makedirs(f, mode=0777)
                    os.umask(original_umask_f)
                if not os.path.exists(g):
                    original_umask_g = os.umask(0)
                    os.makedirs(g, mode=0777)
                    os.umask(original_umask_g)
                if not os.path.exists(h):
                    original_umask_h = os.umask(0)
                    os.makedirs(h, mode=0777)
                    os.umask(original_umask_h)
#       EDITORIAL VARIABLES
                if not os.path.exists(i):
                    original_umask_i = os.umask(0)
                    os.makedirs(i, mode=0777)
                    os.umask(original_umask_i)
                if not os.path.exists(j):
                    original_umask_j = os.umask(0)
                    os.makedirs(j, mode=0777)
                    os.umask(original_umask_j)
                if not os.path.exists(k):
                    original_umask_k = os.umask(0)
                    os.makedirs(k, mode=0777)
                    os.umask(original_umask_k)
                if not os.path.exists(l):
                    original_umask_l = os.umask(0)
                    os.makedirs(l, mode=0777)
                    os.umask(original_umask_l)
                if not os.path.exists(m):
                    original_umask_m = os.umask(0)
                    os.makedirs(m, mode=0777)
                    os.umask(original_umask_m)
                if not os.path.exists(n):
                    original_umask_n = os.umask(0)
                    os.makedirs(n, mode=0777)
                    os.umask(original_umask_n)
                if not os.path.exists(o):
                    original_umask_o = os.umask(0)
                    os.makedirs(o, mode=0777)
                    os.umask(original_umask_o)
#       ANIMATION VARIABLES
                if not os.path.exists(p):
                    original_umask_p = os.umask(0)
                    os.makedirs(p, mode=0777)
                    os.umask(original_umask_p)
                if not os.path.exists(q):
                    original_umask_q = os.umask(0)
                    os.makedirs(q, mode=0777)
                    os.umask(original_umask_q)
                if not os.path.exists(r):
                    original_umask_r = os.umask(0)
                    os.makedirs(r, mode=0777)
                    os.umask(original_umask_r)
#       GRADE VARIABLES
                if not os.path.exists(s):
                    original_umask_s = os.umask(0)
                    os.makedirs(s, mode=0777)
                    os.umask(original_umask_s)
                if not os.path.exists(t):
                    original_umask_t = os.umask(0)
                    os.makedirs(t, mode=0777)
                    os.umask(original_umask_t)
                if not os.path.exists(u):
                    original_umask_u = os.umask(0)
                    os.makedirs(u, mode=0777)
                    os.umask(original_umask_u)
#       VFX VARIABLES
                if not os.path.exists(v):
                    original_umask_v = os.umask(0)
                    os.makedirs(v, mode=0777)
                    os.umask(original_umask_v)
                if not os.path.exists(w):
                    original_umask_w = os.umask(0)
                    os.makedirs(w, mode=0777)
                    os.umask(original_umask_w)
                if not os.path.exists(x):
                    original_umask_x = os.umask(0)
                    os.makedirs(x, mode=0777)
                    os.umask(original_umask_x)
#       REF&TREATMENTS VARIABLES
                if not os.path.exists(y):
                    original_umask_y = os.umask(0)
                    os.makedirs(y, mode=0777)
                    os.umask(original_umask_y)
#       DELIVERABLES VARIABLES
                if not os.path.exists(z):
                    original_umask_z = os.umask(0)
                    os.makedirs(z, mode=0777)
                    os.umask(original_umask_z)
                if not os.path.exists(aa):
                    original_umask_aa = os.umask(0)
                    os.makedirs(aa, mode=0777)
                    os.umask(original_umask_aa)
                if not os.path.exists(ab):
                    original_umask_ab = os.umask(0)
                    os.makedirs(ab, mode=0777)
                    os.umask(original_umask_ab)
                if not os.path.exists(ac):
                    original_umask_ac = os.umask(0)
                    os.makedirs(ac, mode=0777)
                    os.umask(original_umask_ac)
                if not os.path.exists(ad):
                    original_umask_ad = os.umask(0)
                    os.makedirs(ad, mode=0777)
                    os.umask(original_umask_ad)
                if not os.path.exists(ae):
                    original_umask_ae = os.umask(0)
                    os.makedirs(ae, mode=0777)
                    os.umask(original_umask_ae)
                if not os.path.exists(af):
                    original_umask_af = os.umask(0)
                    os.makedirs(af, mode=0777)
                    os.umask(original_umask_af)
                if not os.path.exists(ag):
                    original_umask_ag = os.umask(0)
                    os.makedirs(ag, mode=0777)
                    os.umask(original_umask_ag)
                if not os.path.exists(ah):
                    original_umask_ah = os.umask(0)
                    os.makedirs(ah, mode=0777)
                    os.umask(original_umask_ah)

#       THE FOLLOWING LINES WILL CREATE A hidden "store.dat" FILE THAT WILL LET AWS S3 UPLOAD THE ENTIRE FOLDER STRUCTURE


#def touch(path):
 #   with open(path, 'w'):
  #      os.utime(path, None)


#open('001_DATALAB/file.txt', 'w').close()


# Open a file
fobj = open("001_DATALAB/store.dat", "w")
fobj.write( "Python test");

# Close opend file
fobj.close()
#open('001_DATALAB/file.txt', 'w').close()
Reply


Messages In This Thread
Recursively create a file - by digitalquake - Nov-02-2016, 12:00 PM
RE: Recursively create a file - by Ofnuts - Nov-02-2016, 05:21 PM
RE: Recursively create a file - by digitalquake - Nov-02-2016, 06:16 PM
RE: Recursively create a file - by Ofnuts - Nov-02-2016, 06:33 PM
RE: Recursively create a file - by digitalquake - Nov-03-2016, 10:02 AM
RE: Recursively create a file - by wavic - Nov-03-2016, 11:08 AM
RE: Recursively create a file - by Ofnuts - Nov-03-2016, 02:10 PM
RE: Recursively create a file - by digitalquake - Nov-03-2016, 04:29 PM
RE: Recursively create a file - by Ofnuts - Nov-03-2016, 10:26 PM
RE: Recursively create a file - by digitalquake - Nov-09-2016, 06:35 PM
RE: Recursively create a file - by digitalquake - Nov-14-2016, 03:44 PM
RE: Recursively create a file - by metulburr - Nov-14-2016, 04:08 PM
RE: Recursively create a file - by digitalquake - Nov-25-2016, 10:43 AM
RE: Recursively create a file - by Ofnuts - Nov-25-2016, 02:52 PM
RE: Recursively create a file - by digitalquake - Nov-25-2016, 03:46 PM
RE: Recursively create a file - by nilamo - Dec-06-2016, 07:59 PM
RE: Recursively create a file - by Ofnuts - Nov-25-2016, 10:07 PM
RE: Recursively create a file - by digitalquake - Nov-28-2016, 09:27 AM
RE: Recursively create a file - by digitalquake - Dec-07-2016, 11:22 AM
RE: Recursively create a file - by Larz60+ - Dec-07-2016, 06:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create Choices from .ods file columns cspower 3 643 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  Recommended way to read/create PDF file? Winfried 3 2,935 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  Use PM4PY and create working file thomaskissas33 0 703 Nov-14-2023, 06:53 AM
Last Post: thomaskissas33
  Create csv file with 4 columns for process mining thomaskissas33 3 796 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  create exe file for linux? korenron 2 993 Mar-22-2023, 01:42 PM
Last Post: korenron
  my first file won't create itself MehHz2526 2 917 Nov-27-2022, 12:58 AM
Last Post: MehHz2526
  Create multiple/single csv file for each sql records mg24 6 1,443 Sep-29-2022, 08:06 AM
Last Post: buran
Sad pandas writer create "corrupted" file freko75 1 2,856 Jun-14-2022, 09:57 PM
Last Post: snippsat
  How to return the next page from json recursively? sandson 0 1,176 Apr-01-2022, 11:01 PM
Last Post: sandson
  create new log file on logging? korenron 6 2,348 Mar-22-2022, 07:14 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020