当前位置:网站首页>Group a large number of files in the same folder into multiple groups according to settings
Group a large number of files in the same folder into multiple groups according to settings
2022-06-10 18:23:00 【_ Embarrassing_】
Group a large number of files in the same folder into multiple groups according to the settings
- Demand analysis
stayreconThere are a lot of files under the folder , Observe the file name , We designed the document according torecon_Group by the first number after , Then the resulting folder should be0,1,…,11.
- Programming
Based on the above illusion , We have written the following program , Copy it toreconJust run under the folder .
The experimental results are as follows :#!/usr/bin/env python import subprocess, threading, time, shutil, os, sys import re file_list = os.listdir() file_set = { } pattern = 'recon_(\d*)_' for file in file_list: result = re.match(pattern, file) if result == None: continue if result.group(1) not in file_set.keys(): file_set[result.group(1)] = [] file_set[result.group(1)].append(file) for key in file_set.keys(): os.path.exists(key) or os.mkdir(key) for item in file_set[key]: mv_cmd = ['mv', item, key] subprocess.call(mv_cmd) print(file_set.keys())
- Expand
If divided according to quantity , For example, a fixed number of files per folder , I think it's the same logic , Get all file names first , To eliminatesplit.py, Create a new folder , Partition file .
边栏推荐
- 自定义类型:结构体
- NaturalSpeech模型合成语音在CMOS测试中首次达到真人语音水平
- Abbexa 细菌基因组 DNA 试剂盒介绍
- Record of cmake and GCC installation
- Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE tha
- Linear mobile chess
- Abbexa 无细胞 DNA 试剂盒说明书
- Wireshark学习笔记(一)常用功能案例和技巧
- 线性移动棋
- Generate XML based on annotations and reflection
猜你喜欢

LoRa模块无线收发通信技术详解

CDGA|工业企业进行数据治理的六个关键点

(CVPR 2020) RandLA-Net: Efficient Semantic Segmentation of Large-Scale Point Clouds

正斜杠“/”、反斜杠“\、”转义字符“\”、文件路径分割符傻傻记不清楚

The short ticket hypothesis: finding sparse, trainable neural networks

Canvas fire burning H5 animation JS special effects

True thesis of information system project manager in the first half of 2022

Adding rendererdata of URP with script

改变世界的开发者丨玩转“俄罗斯方块”的瑶光少年

使用Canvas实现的噪音线条h5js特效
随机推荐
最新好文 | 基于因果推断的可解释对抗防御
系统需要把所有文件扫描一遍,并尝试识别视频的封面
踩坑了,BigDecimal 使用不当,造成P0事故!
Abbexa低样本量鸡溶菌酶 C (LYZ) ELISA 试剂盒
搭建在线帮助中心,轻松帮助客户解决问题
LeetCode 321. 拼接最大數***
JS special effect of canvas divergent particle H5 animation
Some views on the current CIM (bim+gis) industry
Generate XML based on annotations and reflection
换根呀呀啊呀
One of the Taobao short video pit avoidance Guide Series -- thoroughly understand Taobao short video
IP summary (tcp/ip volumes 1 and 2)
afl-fuzz多线程
Container containing the most water
使用Canvas实现的噪音线条h5js特效
The development of flutter in digital life and the landing practice of Tianyi cloud disk
2022上半年信息系统项目管理师论文真题
[technical analysis] discuss the production process and technology of big world games - preliminary process
阅读micropyton源码-添加C扩展类模块(2)
Wireshark学习笔记(一)常用功能案例和技巧