Title basically, I need to parse the date modified, the time and seconds in order to reconstruct the filenames in the format of an android phone’s camera roll.

I should be able to make the script once I know how to parse the metadata is all

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    ·
    1 year ago

    maybe something like this using mediainfo and exiftool?

    #!/bin/bash
    
    for file in *.jpg *.mp4; do
        # Extract date and time from file's metadata
        if [[ $file == *.jpg ]]; then
            datetime=$(exiftool -DateTimeOriginal -d "%Y%m%d_%H%M%S" "$file" | awk -F': ' '{print $2}')
        else
            datetime=$(mediainfo --Output="General;%File_Modified_Date%" "$file" | awk -F' ' '{print $1"_"$2}' | tr -d ':' | tr -d '-')
        fi
    
        # If datetime was found, rename the file 
        if [ -n "$datetime" ]; then
            # Extract extension of file 
            ext="${file##*.}"
            # Rename file with date and time as prefix (remove echo after testing it)
            echo mv -- "$file" "${datetime}.${ext}"
        fi
    
    done
    
  • db2@lemmy.one
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    1 year ago

    Use ffprobe to get video info, it makes it dead easy. Practically a one liner.

  • 𝘋𝘪𝘳𝘬@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    You could use stat to get this information based on the file itself. And with jhead for example you can get the additional meta data in the files, stored in the EXIF and IPTC tags.

    Both can be used in scripts.

  • sibloure@beehaw.org
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    1 year ago

    I’ve been using ChatGPT to help come up with bash scripts like this. Make sure you test the script out on a folder of dummy files first if you’re not sure.

        • INeedMana@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          1 year ago

          AFAIK no and yes ;)

          It sends only the comment where the bot is referenced (no context, no chaining. Each comment is a separate prompt) and it does use the private account of the creator. In the topic where it got announced you can see that at some point it ran out of limit and started generating using 3.5