this post was submitted on 12 Jul 2023
14 points (85.0% liked)

Linux

48033 readers
1042 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 1 year ago* (last edited 1 year ago) (2 children)

Let's see

Hi @[email protected] , write a bash script that extracts date of modification including seconds from all .jpg and .mp4 files in the current directory and prints it out

[–] [email protected] 2 points 1 year ago (1 children)

cool thing. I assume it works by piping the linked comments to the API, with the private API key of the bot maker?

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

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

[–] [email protected] 2 points 1 year ago

right. makes sense. thanks for digging into this monster thread tho.

may your day be blessed.

[–] [email protected] 1 points 1 year ago (1 children)

Sure, here is a simple Bash script which uses the stat command to get the modification time of files. It looks specifically for .jpg and .mp4 files in the current directory and prints out the modification date and time, including seconds:

#!/bin/bash

# Iterate over .jpg and .mp4 files in the current directory
for file in *.{jpg,mp4}; do
    # Check if the file exists before trying to extract the date
    if [ -e "$file" ]; then
        # Use stat to extract modification date and print it out
        echo "$file - Modification Date: $(stat -c %y "$file")"
    fi
done

This script will print out the filename along with its modification date for each .jpg and .mp4 file.

You can use this script by saving it in a file (for example, filedate.sh), making it executable with chmod +x filedate.sh, and running it with ./filedate.sh.

Please note that the date format of the stat command can vary based on your system. The %y format outputs the last modification time in human readable format (yyyy-mm-dd hh:mm:ss.sssssssss +zone). You might need to adjust this if you are using a system where stat behaves differently.

Also keep in mind that this script does not traverse directories recursively. It only looks for the specified files in the directory where it is executed. If you need to perform this operation on files in subdirectories, you will need to modify the script slightly or use a different approach.

[–] [email protected] 0 points 1 year ago

@[email protected] does it look like something you are looking for? The check for file existence is unneeded IMO and using the file variable name occludes another binary but in this case it shouldn't hurt the execution