Skip to main content

๐Ÿ“ File Module Guide

This page is currently only available in Chinese. Please switch to ็ฎ€ไฝ“ไธญๆ–‡ for the full content.

๐Ÿ“ File Module Guide

The File module focuses on batch file management, especially rename and search.

Core Scenariosโ€‹

Batch Rename (Replace)โ€‹

import office
office.file.replace4filename(
path='./photos/',
del_content='IMG_',
replace_content='travel_'
)

Add Prefix / Suffixโ€‹

office.file.file_name_add_prefix(file_path='./docs/', prefix_content='2026_')
office.file.file_name_add_postfix(file_path='./docs/', postfix_content='_v1')

Export File Names to Excelโ€‹

office.file.output_file_list_to_excel(dir_path='./docs/')

Search Files by Typeโ€‹

files = office.file.get_files(path='./', suffix='.xlsx', sub=True)
print(f"Found {len(files)} Excel files")

Full API see File API Reference

AI ๅŠžๅ…ฌๆ•ˆ็އ่ฏพ
35 ่ฎฒ AI ่‡ชๅŠจๅŒ–ๅŠžๅ…ฌๅฎžๆˆ˜่ฏพ็”จ Python + AI ๅค„็† Excelใ€Wordใ€PDFใ€้‚ฎไปถ็ญ‰ๅŠžๅ…ฌๅœบๆ™ฏใ€‚
ๅŽปๅญฆไน