def detect_pth(args):
    target = args[2]
    if (target.endswith('.jpeg') or target.endswith('.jpg')):
        try:
            _ = open(target)
        except:
            print('error pic')
            sys.exit(0)
        else:
            return ('pic', target)
    else:
        try:
            os.stat(target)
        except:
            print('error folder')
            sys.exit(0)
        else:
            if (not target.endswith('/')):
                target += '/'
            try:
                os.stat(target)
            except:
                print('error detecting the path')
                sys.exit(0)
            return ('folder', target)
def detect_pth(args):
    target = args[2]
    if (target.endswith('.jpeg') or target.endswith('.jpg')):
        try:
            _ = open(target)
        except:
            print('error pic')
            sys.exit(0)
        else:
            return ('pic', target)
    else:
        try:
            os.stat(target)
        except:
            print('error folder')
            sys.exit(0)
        else:
            if (not target.endswith('/')):
                target += '/'
            try:
                os.stat(target)
            except:
                print('error detecting the path')
                sys.exit(0)
            return ('folder', target)