【英文文件名格式化工具.exe】一键规范文件名,学术党必备!还在手动调整论文标题格式?
分享一款超实用的文件重命名工具,支持多种学术规范命名方式,自动处理标点和大小写,彻底解放双手~
不限于PDF文件,适用于所有英文文件名文件~
核心功能:
1.三种命名格式一键切换:
除介词外首字母大写(of/to等介词小写)仅标题首字母大写(其余全小写)全部字母大写(强调格式)
2.智能处理标点:删除@#等字符,中文冒号“:”后首字母强制大写
3. 可视化操作:支持文件预览、批量选择,重命名前可查看效果
使用场景:
整理文献库时统一标题格式投稿前规范论文文件名批量处理各类英文命名文件格式
使用方法:
1. 运行程序后点击"选择文件"
2. 选择命名格式
3. 预览效果无误后点击"执行重命名"
工具为绿色单文件版,无需安装Python环境,直接双击运行~ 再也不用逐个修改文件名啦!
下载地址:
通过网盘分享的文件:文件名格式化重命名工具.exe链接: https://pan.baidu.com/s/1F7R00BvllUtZBNbRtUeQJQ?pwd=9jk4 提取码: 9jk4
我用夸克网盘分享了「文件名格式化重命名工具.exe」,点击链接即可保存。打开「夸克APP」,无需下载在线播放视频,畅享原画5倍速,支持电视投屏。链接:https://pan.quark.cn/s/3b675c84374d(附:python程序)
[Python] - import os
- import re
- import tkinter as tk
- from tkinter import filedialog, ttk, messagebox
- # 定义需要小写的介词列表(仅用于第一种命名方式)
- prepositions = {'of', 'to', 'in', 'for', 'on', 'with', 'at', 'by',
- 'from', 'up', 'about', 'as', 'but', 'or', 'and'}
- class FileRenamerGUI:
- def __init__(self, root):
- self.root = root
- self.root.title("文件名格式化重命名工具")
- self.root.geometry("800x600")
- self.root.resizable(True, True)
- # 设置中文字体支持
- self.setup_fonts()
- # 存储选中的文件
- self.selected_files = []
- # 命名方式选择变量(1: 除介词外首字母大写, 2: 仅首字母大写, 3: 全部大写)
- self.naming_style = tk.IntVar(value=1)
- # 创建界面组件
- self.create_widgets()
- def setup_fonts(self):
- """设置支持中文的字体"""
- default_font = ('SimHei', 10)
- self.root.option_add("*Font", default_font)
- def create_widgets(self):
- """创建GUI组件"""
- # 创建主框架
- main_frame = ttk.Frame(self.root, padding="10")
- main_frame.pack(fill=tk.BOTH, expand=True)
- # 标题标签
- title_label = ttk.Label(main_frame, text="文件名格式化重命名工具", font=('SimHei', 14, 'bold'))
- title_label.pack(pady=10)
- # 命名方式选择框架
- style_frame = ttk.LabelFrame(main_frame, text="命名方式", padding="5")
- style_frame.pack(fill=tk.X, pady=5)
- # 命名方式单选按钮
- ttk.Radiobutton(
- style_frame,
- text="除介词外全部单词首字母大写(默认)",
- variable=self.naming_style,
- value=1
- ).pack(anchor=tk.W, padx=5, pady=2)
- ttk.Radiobutton(
- style_frame,
- text="仅首字母大写(其余小写)",
- variable=self.naming_style,
- value=2
- ).pack(anchor=tk.W, padx=5, pady=2)
- ttk.Radiobutton(
- style_frame,
- text="全部字母大写",
- variable=self.naming_style,
- value=3
- ).pack(anchor=tk.W, padx=5, pady=2)
- # 按钮框架
- button_frame = ttk.Frame(main_frame)
- button_frame.pack(fill=tk.X, pady=5)
- # 选择文件按钮
- select_btn = ttk.Button(button_frame, text="选择文件", command=self.select_files)
- select_btn.pack(side=tk.LEFT, padx=5)
- # 清除选择按钮
- clear_btn = ttk.Button(button_frame, text="清除选择", command=self.clear_selection)
- clear_btn.pack(side=tk.LEFT, padx=5)
- # 重命名按钮
- rename_btn = ttk.Button(button_frame, text="执行重命名", command=self.perform_rename)
- rename_btn.pack(side=tk.RIGHT, padx=5)
- # 预览按钮
- preview_btn = ttk.Button(button_frame, text="预览效果", command=self.preview_changes)
- preview_btn.pack(side=tk.RIGHT, padx=5)
- # 文件列表框架
- list_frame = ttk.LabelFrame(main_frame, text="选中的文件", padding="5")
- list_frame.pack(fill=tk.BOTH, expand=True, pady=5)
- # 创建文件列表
- columns = ('original', 'new_name')
- self.file_tree = ttk.Treeview(list_frame, columns=columns, show='headings')
- # 设置列标题
- self.file_tree.heading('original', text='原始文件名')
- self.file_tree.heading('new_name', text='新文件名(预览)')
- # 设置列宽
- self.file_tree.column('original', width=350)
- self.file_tree.column('new_name', width=350)
- # 添加滚动条
- scrollbar = ttk.Scrollbar(list_frame, orient=tk.VERTICAL, command=self.file_tree.yview)
- self.file_tree.configure(yscroll=scrollbar.set)
- # 布局列表和滚动条
- self.file_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
- scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- # 状态标签
- self.status_var = tk.StringVar()
- self.status_var.set("就绪 - 请选择文件")
- status_label = ttk.Label(main_frame, textvariable=self.status_var, relief=tk.SUNKEN, anchor=tk.W)
- status_label.pack(fill=tk.X, side=tk.BOTTOM, pady=5)
- def process_colon_part(self, part):
- """处理冒号后的部分,确保首字母大写"""
- if not part.strip():
- return part
- # 分割为单词
- words = re.findall(r'\b\w+\b', part.strip())
- if not words:
- return part
- # 第一个单词首字母大写,其余按当前命名方式处理
- first_word = words[0].lower().capitalize()
- remaining_words = words[1:] if len(words) > 1 else []
- # 根据命名方式处理剩余单词
- style = self.naming_style.get()
- processed_remaining = []
- if style == 1: # 除介词外首字母大写
- for word in remaining_words:
- lower_word = word.lower()
- if lower_word in prepositions:
- processed_remaining.append(lower_word)
- else:
- processed_remaining.append(lower_word.capitalize())
- elif style == 2: # 仅首字母大写,其余小写
- processed_remaining = [word.lower() for word in remaining_words]
- elif style == 3: # 全部大写
- processed_remaining = [word.upper() for word in remaining_words]
- return first_word + (' ' + ' '.join(processed_remaining) if processed_remaining else '')
- def format_title(self, title):
- """根据选择的命名方式格式化标题,处理冒号并替换为中文冒号"""
- # 将所有英文冒号替换为中文冒号后再处理
- title_with_chinese_colon = title.replace(':', ':')
- # 分割冒号前后部分(使用中文冒号分割)
- if ':' in title_with_chinese_colon:
- parts = title_with_chinese_colon.split(':', 1) # 只分割一次
- main_part = parts[0].strip()
- colon_part = parts[1].strip() if len(parts) > 1 else ''
- # 处理主部分
- processed_main = self.format_main_part(main_part)
- # 处理冒号后部分(首字母强制大写)
- processed_colon = self.process_colon_part(colon_part)
- return f"{processed_main}:{processed_colon}" if processed_colon else processed_main
- else:
- return self.format_main_part(title_with_chinese_colon)
- def format_main_part(self, main_part):
- """处理标题主部分(冒号前的内容)"""
- words = re.findall(r'\b\w+\b', main_part)
- if not words:
- return main_part
- style = self.naming_style.get()
- if style == 1: # 除介词外首字母大写
- formatted = []
- for word in words:
- lower_word = word.lower()
- if lower_word in prepositions:
- formatted.append(lower_word)
- else:
- formatted.append(lower_word.capitalize())
- return ' '.join(formatted)
- elif style == 2: # 只有标题首字母大写,其余小写
- if not words:
- return main_part
- # 第一个单词首字母大写,其余小写
- first_word = words[0].lower().capitalize()
- other_words = [word.lower() for word in words[1:]]
- return ' '.join([first_word] + other_words)
- elif style == 3: # 全部字母大写
- return ' '.join([word.upper() for word in words])
- def select_files(self):
- """打开文件选择对话框选择文件"""
- files = filedialog.askopenfilenames(
- title="选择要重命名的文件",
- filetypes=[("所有文件", "*.*")]
- )
- if files:
- # 清除之前的预览
- for item in self.file_tree.get_children():
- self.file_tree.delete(item)
- # 存储并显示选中的文件
- self.selected_files = list(files)
- for file_path in self.selected_files:
- dir_name, file_name = os.path.split(file_path)
- name, ext = os.path.splitext(file_name)
- new_name = self.format_title(name) + ext
- self.file_tree.insert('', tk.END, values=(file_name, new_name))
- self.status_var.set(f"已选择 {len(self.selected_files)} 个文件")
- def clear_selection(self):
- """清除选中的文件"""
- self.selected_files = []
- for item in self.file_tree.get_children():
- self.file_tree.delete(item)
- self.status_var.set("已清除选择 - 请重新选择文件")
- def preview_changes(self):
- """预览重命名效果"""
- if not self.selected_files:
- messagebox.showinfo("提示", "请先选择文件")
- return
- # 更新预览
- for i, file_path in enumerate(self.selected_files):
- dir_name, file_name = os.path.split(file_path)
- name, ext = os.path.splitext(file_name)
- new_name = self.format_title(name) + ext
- self.file_tree.item(self.file_tree.get_children()[i], values=(file_name, new_name))
- self.status_var.set(f"已更新 {len(self.selected_files)} 个文件的预览效果")
- def perform_rename(self):
- """执行文件重命名操作"""
- if not self.selected_files:
- messagebox.showinfo("提示", "请先选择文件")
- return
- success_count = 0
- error_count = 0
- error_files = []
- for file_path in self.selected_files:
- try:
- dir_name, file_name = os.path.split(file_path)
- name, ext = os.path.splitext(file_name)
- new_name = self.format_title(name) + ext
- new_path = os.path.join(dir_name, new_name)
- if file_path != new_path: # 只有当文件名有变化时才重命名
- os.rename(file_path, new_path)
- success_count += 1
- except Exception as e:
- error_count += 1
- error_files.append(f"{file_name}: {str(e)}")
- # 显示结果
- result_msg = f"重命名完成!\n成功: {success_count} 个文件\n失败: {error_count} 个文件"
- if error_files:
- result_msg += "\n\n错误详情:\n" + "\n".join(error_files)
- messagebox.showinfo("操作结果", result_msg)
- # 清除选择
- self.clear_selection()
- if __name__ == "__main__":
- root = tk.Tk()
- app = FileRenamerGUI(root)
- root.mainloop()
复制代码
|