Code Monkey home page Code Monkey logo

organizeart's Introduction

OrganizeArt.py

This Python script can modify the timestamp of a media file downloaded from Twitter/X. This can assist users who download large batches of pictures (such as artwork, photographs, videos, etc.) and like to organize the typically random filenames by their original upload date & time. This is beneficial to those who enjoy viewing their libraries in a large thumbnail view while being able to sort chronologically.

Usage

python OrganizeArt.py directory

All files in the specified directory named after a valid Twitter ID will have their timestamps replaced. The timestamps are relative to GMT and will display appropriately depending on your system's timezone or locale. The original content of the files themselves will remain untouched.

Before After
Before After

How It Works

The script works by decoding the snowflake ID from the filename's Twitter ID, which is a unique 15-character identifier assigned to each Twitter object. The algorithm for extracting the Unix timestamp is as follows:

  1. Read the Twitter ID from the filename.
  2. Get the snowflake ID by decoding the Twitter ID's base64 string and adding padding if required.
  3. Get the first 16 bytes of the snowflake ID (the Unix timestamp).
  4. Add the constant Twitter epoch to the result, which is 1288834974657 (or Thursday, November 4, 2010 1:42:54.657 AM).

More information about snowflake IDs: https://en.wikipedia.org/wiki/Snowflake_ID

organizeart's People

Contributors

anub1sr0cks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.