我正在尝试制作一个可以在 Windows 机器上打乱文件夹文件和文件内容的脚本。
这是我第一次尝试打乱文件夹中的文件名。我知道在性能方面它可能很糟糕,而且看起来很可悲,但我是新手,并试图自学。
import os
import sys
import re
root = 'C:/Users/Any/Desktop/test'
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' A', ' ಌ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' B', ' ௷'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' C', ' അ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' D', 'ጯ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' E', 'ᚙ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' F', ' ᚘ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' G', ' ௲ '))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' H', ' ණ '))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' I', ' ┩'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' J', ' ວ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' K', ' ʥ '))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' L', ' ቄ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' M', ' ఈ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' N', '㏁'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' O', ' Ꮄ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' P', '♙'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' Q', ' Ꮬ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' R', ' ꡤ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' S', ' ⏎'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' T', ' ௷'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' U', ' ヌ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' V', ' ஹ '))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' W', ' ̉'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' X', ' ฟ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' Y', ' ॢ'))
for item in os.listdir(root):
fullpath = os.path.join(root, item)
os.rename(fullpath, fullpath.replace(' Z', ' ╔'))
运行脚本之前的文件夹内容为:
FILENAMEABCDEFGHIJKLMNOPQRSTUVWSTXYZ.docx
TEST PICTURE.jpg
TEST SCRIPT.bat
TEST TEXT.txt
运行脚本后:
FILENAMEABCDEFGHIJKLMNOPQRSTUVWSTXYZ.docx
TEST ௷EXT.txt
TEST âŽCRIPT.bat
TESTâ™™ICTURE.jpg
那么到底发生了什么?本来就是这么简单,怎么会产生这样的结果呢?我应该怎么做才能尝试制作一个加扰脚本,它不一定是预先的,因为我想理解它。