def delete_unwanted_files():

    allfiles = list(fs.get_all_files(cf.working_dir))

    # delete unwanted files
    for file in allfiles:

        fileinfo = file_info(file, cf.working_dir)

        # skip is exclude pattern found
        if fileinfo.excludefilereorg:
            #pr.print_(fileinfo.fullfilename, "delskip")
            continue

        # if contact sheet
        if (fileinfo.extension == cf.contact_ext):
            # make sure matching video file exists
            if not corresponding_video_file_exists(fs.filename_only(file),
                                                   allfiles):
                # if no matching video file, delete
                fs.delete_file(file)
        # if is not contact sheet or video file, delete
        elif (fileinfo.extension
              not in cf.video_ext) or ('sample' in fileinfo.filename.lower()):
            fs.delete_file(file)
def rename_move():

    # rename video file name and move to parent
    allfiles = list(fs.get_all_files(cf.working_dir))

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

        # object to parse out file path parts
        fileinfo = file_info(file, cf.working_dir)

        # skip file is not video or marked for omit reorg
        if (fileinfo.extension not in cf.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
        pr.print_(fileinfo.fullfilename)
        pr.print_(newfilename)
        fs.move_file(fileinfo.fullfilename, newfilename)

    # delete subdirs
    all_sub_dirs = fs.get_all_subdir(cf.working_dir)
    for dir in all_sub_dirs:
        if len(list(fs.get_all_files(dir))) == 0:
            delete_folder(dir)
Пример #3
0
    in_path = str(sys.argv[1]).strip().replace('"', '')

    if (len(sys.argv) > 2 and sys.argv[2] == 'skip'):
        cf.remove_lowres = False

    if os.path.isdir(in_path):
        cf.thumb_paths = [in_path]
        pr.print_(in_path, "path")

ii = 1
all_ct = 0
thumb_files = []

for dir in cf.thumb_paths:

    files = list(fs.get_all_files(dir))

    for file in files:

        file_nfo = file_info(file, dir)

        if file_nfo.extension.lower() in cf.video_ext:

            if not fn.corresponding_contact_sheet_exists(
                    file_nfo.fullfilename, files):

                thumb_files.append(file_nfo)

all_ct = len(thumb_files)

for thumb_file in thumb_files: