Rename YYYYMMDD format files to serial numbers

Since the image data that has been updated every day since January 2008 has been stored on the server at work. I renamed the file names to serial numbers and made a video with ffmpeg.

--From the original file status_20080101.png --After conversion status_0001.png etc.

Is YYYYMMDD once converted to Date format, compared, sorted, and then renamed? I thought it was easier. It was sorted by glob and listed in order of date.

rename.py


import os
import glob

file_list = sorted(glob.glob('status_????????.png'))

for num,filename in enumerate(file_list):
    os.rename(filename , 'status_' + '{0:04d}'.format(num) + '.png')

See below for how to source serial number images with ffmpeg (Qiita) Generate video from serial number image with ffmpeg / Generate serial number image from video ~ How to prevent dropped frames ~

Since I made a video of the ice grid data on the surface of the ocean released by NOAA (National Oceanic and Atmospheric Administration) It was interesting to see how the ice in the polar regions increases and decreases depending on the season, but can't you put a video on Qiita? So that's it for the time being.

Recommended Posts

Rename YYYYMMDD format files to serial numbers
Easy way to rename files
How to add page numbers to PDF files (in Python)
Convert translation resource files (.po) to XLIFF format (.xlf)
Format numbers into currency format
Python / datetime> Implementation to convert YYYYMMDD format to YYYY / MM / DD
Linux script to convert Markdown files from JupyterLab format to Qiita format
Convert only date serial numbers in CSV files with awk