コード例 #1
0
def DeleteUnwatedFiles(workingdir):

    allfiles = list(fs.GetAllFiles(workingdir))

    # delete unwanted files
    for file in allfiles:

        fileinfo = FileInfo(file, workingdir)

        # if contact sheet
        if (fileinfo.extension == conf.contact_ext):
            # make sure matching video file exists
            if not CorrespondingVideoFileExists(fs.FileNameOnly(file),
                                                conf.video_ext, allfiles):
                # if no matching video file, delete
                fs.DeleteFile(file)
        # if is not contact sheet or video file, delete
        elif (fileinfo.extension
              not in conf.video_ext) or ('sample'
                                         in fileinfo.filename.lower()):
            fs.DeleteFile(file)
コード例 #2
0
def RenameMove(workingdir):

    # rename video file name and move to parent
    allfiles = list(fs.GetAllFiles(workingdir))

    # move video files to working folder root
    for file in allfiles:

        # object to parse out file path parts
        fileinfo = FileInfo(file, workingdir)

        # skip file is not video or marked for omit reorg
        if (fileinfo.extension not in conf.video_ext) \
         or fileinfo.isatroot \
         or fileinfo.excludefilereorg:
            continue

        # unique counter
        iterator = 0
        newfilename = os.path.join(fileinfo.rootfolder, fileinfo.parentfoldername) \
         + fileinfo.extension

        # make filename unique if exists in destination
        while os.path.isfile(newfilename):
            newfilename = os.path.join(fileinfo.rootfolder, fileinfo.parentfoldername) + "-" + \
             ("%02d" % (iterator,)) + fileinfo.extension
            iterator += 1

        # move / rename file to parent root dir
        fs.Movefile(fileinfo.fullfilename, newfilename)

    # delete subdirs

    # get first level subdirs
    subdirs = next(os.walk(workingdir))[1]

    # delete dir is not omit reorg
    for dir in subdirs:
        if not ExcludeInFileReorg(dir):
            shutil.rmtree(os.path.join(workingdir, dir))
コード例 #3
0
import FileSystem as fs
import Functions as fn
import Image as img
import Print as prn

if (len(sys.argv) > 1):

    in_path = str(sys.argv[1]).strip().replace('"', '')

    if os.path.isdir(in_path):
        conf.paths = [in_path]
        prn.print_(in_path, "path")

for dir in conf.paths:

    files = list(fs.GetAllFiles(dir))

    for file in files:

        file_info = FileInfo(file, dir)

        if file_info.extension in conf.video_ext:

            if not fn.CorrespondingContactSheetExists(
                    os.path.join(file_info.folder,
                                 fs.FileNameOnly(file_info.filename)),
                    conf.contact_ext, files):

                try:
                    img.create_contact_sheet(file_info.fullfilename)
                except: