5 major file management operations, Python automated office, everything is clear

Hello everyone, this is programmer Wan Feng.

In the past month or so of updating the open source project: python-office, I have discovered some new requirements. I have sorted them out today and shared them with you~

They are all commonly used tools for automated office work. Netizen: I wish I had known earlier.

1. Batch compress folders

Running out of computer space? Don’t be afraid, just compress the files in batches~

Install third-party libraries

pip install pofile

code

import pofile

pofile.zip4dir(path=r'..\程序员晚枫的文件夹\50-28-zip4dir')

2. Batch rename

Is there an advertisement in the name of the information downloaded from the Internet? Directly delete in batches.

Install third-party libraries

pip install python-office

code

import office

office.file.replace4filename(path=r'./test_files/50-23-replace4filename',
                             del_content='程序员晚枫',
                             replace_content='小H书-程序员晚枫',
                             dir_rename=False,
                             suffix='.py')

3. Find files based on content

Everyone has used it to find files based on their titles.

If I forget the title, have you used it to find the file based on its content?

Install third-party libraries

pip install python-office

code

import office

office.file.search_by_content(
    search_path=r'..\程序员晚枫\50-09-search4content',
    content='import office')

4. Automatically create Excel

Before Python, the only software for processing data was Excel!

Install third-party libraries

pip install poexcel

code

import poexcel

poexcel.fake2excel(columns=['name', 'company', 'phone_number'],
                        rows=10,
                        path=r'./程序员晚枫/50-07-fake2excel/中文-1.xlsx')

5. Automatically organize folders

How many people have folders that are messy and don’t want to sort them out?

With one line of Python code, you can automatically classify and organize files according to their types. Try it now~

Install third-party libraries

pip install pofile

code

# 导入这个库
import pofile

pofile.group_by_name(r"d://程序员晚枫的文件夹")

The above functions all come from python-office, a special library for automated office work. For more functions and video tutorials, you can search on Baidu:python-office

Guess you like

Origin blog.csdn.net/weixin_42321517/article/details/133465459