A Python utility to update video and image file modification dates based on their filenames. This is particularly useful for Google Pixel phone media files, which have filenames like PXL_20240813_051351918.mp4 or PXL_20240815_174155846.NIGHT.jpg containing the date and time when the media was recorded.
- Extracts date and time information from filenames in various formats (see Supported Filename Formats section)
- Updates the "Date Modified" attribute of media files to match the extracted datetime
- The datetime in filenames is assumed to be in UTC and it is for Google Pixel phones.
- Handles multiple file formats (
mp4,mov,avi,mkv,jpg)
- Python 3.6 or higher
pip install name2date- Clone this repository or download the source files
- Navigate to the project directory
- Install the package
pip install .After installation, you can use the command-line tool:
name2date /path/to/mediaAlternatively, you can run the package as a module:
python -m name2date /path/to/mediaThis will process all supported media files (video and image) in the specified directory, extracting date and time from filenames and updating the "Date Modified" attribute. By default, the datetime is interpreted as UTC.
The tool supports two levels of verbosity:
name2date /path/to/media -vThis will print information only about skipped files (files that don't match the expected patterns).
name2date /path/to/media -vvThis will print detailed information about all files being processed, including which files are being processed and updated.
The script is designed to work with various Google Pixel media filenames, which follow these patterns:
PXL_YYYYMMDD_HHMMSSXXX.mp4PXL_YYYYMMDD_HHMMSSXXX.NIGHT.jpgPXL_YYYYMMDD_HHMMSSXXX.MP.jpgPXL_YYYYMMDD_HHMMSSXXX.MP(N).jpg(where N is a number)PXL_YYYYMMDD_HHMMSSXXX(N).jpg(where N is a number)PXL_YYYYMMDD_HHMMSSXXX.RESTORED.jpgPXL_YYYYMMDD_HHMMSSXXX_exported_0_TIMESTAMP.jpg
Where:
YYYY: 4-digit yearMM: 2-digit month (01-12)DD: 2-digit day (01-31)HH: 2-digit hour in 24-hour format (00-23)MM: 2-digit minute (00-59)SS: 2-digit second (00-59)XXX: 3-digit millisecond (000-999)
lv_0_YYYYMMDDHHMMSS.mp4
Where:
YYYY: 4-digit yearMM: 2-digit month (01-12)DD: 2-digit day (01-31)HH: 2-digit hour in 24-hour format (00-23)MM: 2-digit minute (00-59)SS: 2-digit second (00-59)
Examples of supported filenames:
PXL_20240813_051351918.mp4PXL_20240815_174155846.NIGHT.jpgPXL_20240815_190034025.MP.jpgPXL_20240815_190407130(1).jpgPXL_20240815_190849820.RESTORED.jpgPXL_20240811_084139455_exported_0_1723365759303.jpglv_0_20240813134545.mp4
name2date -vv ~/Movies/gphoto