我有一個python程序,可以從文件名中刪除字符串,但我正在尋找使用java的幫助。如何使用java重命名文件
與此類似
import glob,os
from tkinter import filedialog
import re
#in_path = filedialog.askdirectory() # if want to ask for directory
os.chdir(os.path.join("G:\\")) #change to os.chdir(os.path.join(in_path)) to used selected dir
for files in glob.glob("*.mp4"): #get mp4 files
filename = os.path.splitext(files)
ext=filename[-1]
thefile = filename[0]
if "v" in thefile: #if there is version, check where the letter "v" is
ind = thefile.index("v")
change = thefile[:ind].replace(".","").replace("_","")+thefile [ind:].replace("_","")+ext
else:
change = thefile.replace(".","")+ext
os.rename(files,change)
我們理解你,但你應該向我們提出一些Java代碼,而不是蟒蛇 –
也許你可以試試[varycode(https://www.varycode.com/) –