示例#1
0
def getFileInfo(f):
    if Common.is_windows():
        mode = ""
        owner = ""
        group = ""
    else:
        mode = "o{0:o}".format(fs.getAttr(f))
        owner = fs.getOwner(f)
        group = fs.getGroup(f)
    dir_or_link = ""
    if fs.isDirectory(f):
        dir_or_link = "D"
    if fs.isLink(f):
        dir_or_link += "L"
    size = fs.getFileSize(f)
    last = fs.getLastWrite(f)
    filename = fs.getFileName(f)
    item = [mode, dir_or_link, owner, group, size, last, filename]
    return item
示例#2
0
            for dp in dirs1 :
                nd = rename(dp)
                dp = "'" + dp + "'"
                nd = "'" + nd + "'"
                if dp != nd :
                    lines += f"mv -v {dp} {nd}\n"
                    count += 1
    return lines

# 対象のディレクトリを得る。
if Common.count_args() < 2 :
    Common.stop(9, "対象のディレクトリとスクリプトファイルの保存先(パス)を指定してください。")

# 対象のディレクトリ
dir0 = Common.args()[0]
if not fs.isDirectory(dir0) :
    Common.stop(9, f"{dir0} はディレクトリとして存在しません。")

# スクリプトファイルのパス
savePath = Common.args()[1]


# ディレクトリの名前変更コマンドを作成する。
lines = renameDirs(dir0)

# スクリプトを作成する。
try :
    fs.writeAllText(savePath, lines)
    print(f"\n終わり。{savePath} が作成されました。")
except Exception as e :
    Common.esc_print("red", "エラーを検出。{0}".format(e.message))
示例#3
0
                        sf = "r" + Text.substring(ff[1], 2)
                        newname = folder + "/" + ff[0] + "_" + sf
                        fs.move(fpath, newname)
                        print("Renamed: " + newname)
                    else:
                        # 連続番号が3桁かつ300番台以上の場合はサポートしない(スキップする)
                        pass
                else:
                    # 連続番号が2桁の場合
                    #print("Passed: " + fpath)
                    pass
        else:
            #fs.move(fpath, fpath + ".jpg")
            print("Non image passed: " + fpath)
    return


#  スタート
if Common.count_args() == 0:
    folder = Common.readline("対象の画像フォルダを入力します。")
else:
    folder = Common.args(0)

if not fs.isDirectory(folder):
    Common.stop(1, folder + " は正しいディレクトリではありません。")

# 指定されたフォルダの画像ファイルを同じ長さにリネームする。
rename_files(folder)

print("正常終了。")