python获取照片的拍摄日期并重命名

用Python给老照片智能归档:按拍摄日期自动重命名+分类存储(Pillow+exifread) 本文详细介绍了如何使用Python构建一个智能照片归档系统。该系统利用Pillow和ExifRead等库自动读取照片的EXIF元数据,提取拍摄日期,并按年月日自动重命名和分类存储照片,有效解决了海量照片管理混乱的痛点,帮助用户建立有序的数字记忆档案馆。 阅读详情

python获取照片的拍摄日期并重命名。不支持重复处理的中断。

重命名为:拍摄日期__原文件名

import os
import exifread

def getExif(filename):
    FIELD = 'EXIF DateTimeOriginal'
    fd = open(filename, 'rb')
    tags = exifread.process_file(fd)
    fd.close()
    if FIELD in tags:
        new_name = str(tags[FIELD]).replace(':', '').replace(' ', '_') + os.path.splitext(filename)[1]
        tot = 1
        while os.path.exists(new_name):
            new_name = str(tags[FIELD]).replace(':', '').replace(' ', '_') + '_' + str(tot) + os.path.splitext(filename)[1]
            tot += 1

        new_name2 = new_name.split(".")[0] + '__' +filename
        print(new_name2)    
        os.rename(filename, new_name2)
    else:
        print('No {} found'.format(FIELD))

for filename in os.listdir('.'):
    if os.path.isfile(filename):
        getExif(filename)


有拍摄日期的文件数,年轻时多么爱拍照。。。


Python实战:高效解析图片Exif信息,一键获取拍摄时间 本文详细介绍了如何使用Python高效解析图片的Exif信息,特别是如何一键获取拍摄时间。通过Pillow和piexif库的实战应用,文章提供了从单张图片处理到批量自动化管理的完整代码方案,包括错误处理、性能优化及按时间重命名等实用技巧,帮助开发者快速构建自己的图片管理工具。 阅读详情

相关推荐

opencv拍摄并保存视频(基于python)

opencv拍摄并保存视频(基于python),可以直接运行,也可以在这个基础上做高效的二次开发完成项目,节约时间

Python批量重命名iPhone、微信照片,视频-按照拍摄时间重命名

Python批量重命名iPhone、微信照片,视频-按照拍摄时间重命名

wangli_010的专栏 3011

python源码,按拍摄时间整理照片到日期目录下存放

功能:解压到照片目录下,运行photo.exe 支持图片格式: '.jpg','.png','.mp4','.mov','.jpeg','.heic','.gif' 自动将照片目录中的图片和视频,按照拍摄时间整理到对应文件夹(名称格式:2019-01-01)中。

Python读取照片的拍摄时间和地点

使用exifread模块 pip install exifread 非常简单易懂的代码: import os import exifread path = "/home/oliveryty/图片" for file in os.listdir(path): print(file) #exifread处理图片 f = open(path + "/" +file, "rb") tags = exifread.process_file(f) ...

苔原之家 4056

Python实现获取照片拍摄日期并重命名的方法

本文实例讲述了Python实现获取照片拍摄日期并重命名的方法。分享给大家供大家参考,具体如下: python获取照片的拍摄日期并重命名。不支持重复处理的中断。 重命名为:拍摄日期__原文件名 import os import exifread def getExif(filename): FIELD = 'EXIF DateTimeOriginal' fd = open(filename, 'rb') tags = exifread.process_file(fd) fd.close() if FIELD in tags: new_name = str(tags[

CentOS7 安装天气分型软件cost733过程详解

cost733是一款天气分型软件,其内置的一些算法可以帮助气象工作者进行天气类型划分等(我也是初学者,仅仅知道一些皮毛),但是网上找到的安装办法比较少,并且总会出现一些报错,试了一晚上,终于将安装办法调通了,希望可以帮助到大家

weixin_62573024的博客 3552

提取图片中的日期信息

【代码】提取图片中的日期信息。

qq_32636415的博客 1509

解决Qt平台插件初始化失败:This application failed to start because no Qt platform plugin could be initialized

本文深入解析了Qt应用程序启动时常见的‘platform plugin’初始化失败报错,指出其核心在于环境变量冲突或多版本Qt共存导致的插件路径混乱。文章提供了从环境变量检查、路径调整到文件补全的完整解决方案,并给出了使用windeployqt工具等预防性开发实践,帮助用户和开发者彻底解决这一经典问题。

weixin_29229261的博客 2110

python 获取照片拍摄时间_Python实现获取照片拍摄日期并重命名的方法

本文实例讲述了Python实现获取照片拍摄日期并重命名的方法。分享给大家供大家参考,具体如下:python获取照片的拍摄日期并重命名。不支持重复处理的中断。重命名为:拍摄日期__原文件名import osimport exifreaddef getExif(filename):FIELD = 'EXIF DateTimeOriginal'fd = open(filename, 'rb')tags ...

weixin_39981360的博客 503

基于three.js的室内全景3D展馆案例分享

3D场景展厅

acheng 3551

瑞芯微RK3568开发板实战:Android11系统parameter.txt文件配置全解析(附常见问题排查)

本文深入解析了瑞芯微RK3568开发板在Android 11系统下parameter.txt文件的配置要点与实战技巧。作为BootLoader启动阶段的核心蓝图,该文件决定了硬件初始化、分区布局及电源管理。文章详细拆解了身份标识、GPIO控制(PWR_HLD)、命令行参数及分区表等关键字段的配置逻辑,并针对RK3568平台与Android 11特性提供了专项适配策略,最后附带了启动失败、分区异常等常见问题的深度排查方法。

php55的博客 893

python当前时间命名图片_Python实现获取照片拍摄日期并重命名的方法

本文实例讲述了Python实现获取照片拍摄日期并重命名的方法。分享给大家供大家参考,具体如下:python获取照片的拍摄日期并重命名。不支持重复处理的中断。重命名为:拍摄日期__原文件名import osimport exifreaddef getExif(filename):FIELD = 'EXIF DateTimeOriginal'fd = open(filename, 'rb')tags ...

weixin_36096321的博客 724

泛微ecology9 利用字段值动态控制明细表显示与隐藏

本文详细介绍了在泛微ecology9中,如何利用WfForm.bindFieldChangeEvent监听字段变化,结合jQuery动态控制明细表显示与隐藏的实战方法。通过五步操作,可实现根据字段值(如报销类型)智能切换明细表,提升表单交互体验与开发效率,并确保PC与移动端完美兼容。

7z8x2c4v6b9的博客 580

python读取图片文件名_Python实现获取照片拍摄日期并重命名的方法

本文实例讲述了Python实现获取照片拍摄日期并重命名的方法。分享给大家供大家参考,具体如下:python获取照片的拍摄日期并重命名。不支持重复处理的中断。重命名为:拍摄日期__原文件名import osimport exifreaddef getExif(filename):FIELD = 'EXIF DateTimeOriginal'fd = open(filename, 'rb')tags ...

weixin_39916360的博客 430

博途PLC S7-1200/1500 ModbusTcp通信SCL代码篇(轮询)

博途PLC MODBUS TCP的详细讲解和注意事项,可以参看下面这篇博文,这里不在赘述。这篇作为SCL代码篇主要给出SCL语言下的轮训写法和注意事项。博途PLC1200/1500PLC ModbusTcp通信(轮询处理)_RXXW_Dor的博客-CSDN博客。............

RXXW_Dor的博客 8398

【DaVinci Developer专题】-36-创建一个“既读又写”的Sender Receiver Port(SR PR-Port)

有时会遇到SWC需要对一个Port进行“既可以读,也可以写”的操作。以下图为例,Test_A_SWC中Test_A_Port是P-Port;Test_B_SWC中Test_A_Port是R-Port。Test_C_SWC需要对Test_A_Port同时进行“读”和“写”。 该篇将详细介绍PR-Port的创建方法。 目录 1 创建一个S/R Port Interface 2 将一个PR-Port端口添加至Application Component 3 PR-Port端口初始化 4 Run.

「汽车电子助手」的博客 3008

python当前时间命名图片_python获取照片的拍摄日期并重命名(递归命名一个文件夹下的所有照片)...

#-*- coding: UTF-8 -*-#python 3.9.0 64bitimportosimportexifreaddefdealRepateName(info, root, picName, count):'''Description : 处理多张照片有相同拍摄时间的情况,如果多张照片有相同的拍摄时间,则命名格式为:IMG_20170616_221206.JPG,IMG_2017061...

weixin_39624461的博客 883

【Segment Anything Model】三:SAM模型微调自定义数据集,更改混合提示方式:点,框,点框混合

1.微调SAM预备知识。

cvxiayixiao的博客 1万+

python下载文件加上日期_Python实现文件按照日期命名的方法

Python实现文件按照日期命名的方法本文实例讲述了Python实现文件按照日期命名的方法。分享给大家供大家参考。具体实现方法如下:这里实现文件按照创建的时期批量重命名的功能# -*- coding: utf-8 -*-import osimport timeimport datetimerootDir = "I:/1/"dic={}for dirName,subDirs,fileList in ...

weixin_39859954的博客 564

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

python图像批量导入

场景:以前的几千张旧照片,各种扩展名格式的,通过格式工厂统一转成jpg格式,然后通过python检查是否有拍摄日期,如果没有拍摄日期,则将文件的修改时间做为拍摄日期、GPS时间写入。如果文件名不是以IMG_开头的,则将文件重命名为IMG_修改时间,如果文件名冲突,则文件名后加序号。...

小白笔记本 9454

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Python小工具(1)-按照时间顺序将照片进行重命名

python小工具,图片名称的整理

qq_39789508的博客 709

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

python 批量改名程序 用了什么算法_用python实现批量重命名文件的代码

用python实现批量重命名文件的代码下面是最终代码 (windows下实现的)代码如下:# -*- coding: cp936 -*-import ospath = 'D:\\图片\\'for file in os.listdir(path):if os.path.isfile(os.path.join(path,file))==True:if file.find('.')<0:newna...

weixin_39765695的博客 478

批量重命名文件夹:从基础原理到跨平台自动化解决方案

文件管理是计算机操作中的基础概念,其核心在于通过系统化的命名和排序规则实现高效组织。批量重命名的原理基于文件名排序算法和自动化脚本技术,通过前导零编号确保正确的数字序列。这项技术的价值在于显著提升文件管理效率,避免手动操作中的错误和重复劳动。在工程实践中,批量重命名广泛应用于教学资料整理、项目文档管理、照片视频归档等场景。特别是在处理大量文件夹时,PowerShell脚本和Python自动化工具能够实现跨平台的批量编号功能。本文聚焦文件夹重命名技术,深入解析Windows资源管理器、macOS访达以及Lin

weixin_33947521的博客 413
上一篇: sublime Text 3配置
下一篇: python自动申购新股
qzxdh
博客等级 码龄16年 17粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值