this post was submitted on 12 Jul 2023
10 points (81.2% liked)

Linux

48130 readers
489 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

top 10 comments
sorted by: hot top controversial new old
[–] eager_eagle@lemmy.world 17 points 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 8 points 1 year ago* (last edited 1 year ago)

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

[–] Dirk@lemmy.ml 2 points 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.

Date modified can be obtained by ls assuming you haven't touched the files. Ffprobe is your friend for video length.

[–] sibloure@beehaw.org 1 points 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.

[–] PoisonedPrisonPanda@discuss.tchncs.de -4 points 1 year ago (2 children)

Chatgpt is your friend here. ;)

[–] Mechanize@feddit.it 6 points 1 year ago (1 children)

Probably I'm misreading it, but isn't this kind of answer basically saying "google it"?

I don't want to sound rude, but my english is kind of failing me, I'm just curious, but what's the point?

One of the reasons of this kind of public forum is to share knowledge and experiences. ChatGPT is a closed, private, garden where the answer will just die.

I could get a "I don't really know the answer but I used ChatGPT and it gave me this:" followed by a script, or something like that.

I know, this is off-topic and I'm sorry, I'm just really interested in Why, considering it's said multiple times in this comment section.

[–] PoisonedPrisonPanda@discuss.tchncs.de 1 points 1 year ago* (last edited 1 year ago)

chatgpt is built on the foundations of stackoverflow etc. therefore yeah it is kind of googling it.

however the nature of the generative approach of chatgpt gives you tailored answers.

when you google your question you get abstract answers for other related questions. with an explanation of how doing it. e.g. when I dont understand something but want to I will google it - to gain knowledge.

but with chatpgt you can specify - hey I want a functiom that does this and that in prints me a string/double using that format. chatpgt gives me exactly what I want - without fiddling with format strings etc. anithet example is regex. for my field of experience I am no core developer, therefore for me everything is a tool to get what I want. chatpgt can give this me in a more comfortable way. I dont need to master regex. but it is very helpful. therefore Im outsourcing that kind of work.

One of the reasons of this kind of public forum is to share knowledge and experiences. ChatGPT is a closed, private, garden where the answer will just die.

I agree that for a general standpoint this is valid. however for such simple questions we do not need new forums asking about the already discussed stuff. this is just repetition and we do not like duplicates (which is why forum rules are strict about this)

so I dont see any issue here.

could get a "I don't really know the answer but I used ChatGPT and it gave me this:" followed by a script, or something like that.

that is the total responsibility by the user and has nothing to do with chatgpt. its the same as running ambiguous linux commands as sudo. its not the fault of stackoverflow, the reddit thread or linus itself. its the users fault.

therefore if such thing you mentioned happens. but it can be rejected - one should now about the culprits and strenghts of chatgpt.

edit: as you can see the top voted comment is a human made answer (could also be a chatpgt bot?).

so we are not yet doomed. ;)

[–] Gutless2615@ttrpg.network 1 points 1 year ago* (last edited 1 year ago) (1 children)

It literally is. This is a great use case for going down the chat gpt approach. It will help you throw together a script for this quickly.

yeah but in 80% of the time the less complex solutions are more quickly resolved using chatgpt.

waiting for another human is not instantaneous.

load more comments
view more: next ›