• 173 Posts
  • 1.72K Comments
Joined 1 year ago
cake
Cake day: July 17th, 2023

help-circle







  • After a certain age people stop asking you what your favorite dinosaur is, and I think that’s sad.

    My current one’s the Anchiornis, because it’s in the same clade as birds so it’s in their family tree, and it really looks like a prototype of a bird. It had 4 wings for example, but it already looked really birb-y:

    Everybody reading the comments needs to let us know about your favorite dinosaur.


  • hydroptic@sopuli.xyzOPtoAMA requests@lemmy.worldMargotRobbie
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    54 minutes ago

    Well, “clear” and clear; if you read their comments they very much do make it sound like they’re Robbie. I mean, it’s not that I believe any of it 100% and I think it’s probably just a schtick, but an AMA with that particular person would probably be fun in itself anyhow regardless of who’s “driving” that account. Guess we’ll see if/when this thing via her agent does end up happening? 😀









  • Ah sorry lol, I happily assumed you’re just a bit unfamiliar with bash and not programming in general – you’re definitely doing a great job if that’s the case, shell scripting isn’t exactly easy in a lot of ways like you discovered with how spaces in file names can bork things sometimes. But yeah, 11min isn’t terrible at all and if you don’t have to run that script very often there’s not much point in spending time optimizing it.

    Just for future reference in case you end up scripting again, what I was thinking of was instead of processing every filename in $folder_name/**/* one at a time, you could do it in parallel with some creative rewriting, meaning you’d possibly be able to take advantage of having a multicore CPU – but whether it’ll actually be faster depends on a lot of things so it’d basically just have to be tried and timed.

    Something along these lines, totally untested, the script can be further optimized and might not even run as-is, but should give you the idea. Starting off with the script, I modified it to just take a single file name as an argument:

    #!/bin/bash
    # exif_date_filter.sh
    
    if [ $# -eq 0 ]; then
        echo "Usage: $0 <filename>"
        exit 1
    fi
    
    # Concatenate all arguments into one string for the filename, so calling "./script.sh /path/with spaces.jpg" should work without quoting
    filename="$*"
    
    start_range=20170101
    end_range=20201230
    
    DateTimeOriginal=$(/usr/bin/vendor_perl/exiftool -m -d '%Y%m%d' -T -DateTimeOriginal "$filename")
    CreateDate=$(/usr/bin/vendor_perl/exiftool -m -d '%Y%m%d' -T -CreateDate "$filename")
    
    if [[ "$DateTimeOriginal" =~ ^[0-9]+$ ]] || [[ "$CreateDate" =~ ^[0-9]+$ ]]; then
        if  ([ "$DateTimeOriginal" -gt $start_range ] && [ "$DateTimeOriginal" -lt $end_range ]) || 
            ([ "$CreateDate" -gt $start_range ] && [ "$CreateDate" -lt $end_range ]); then
            /usr/bin/vendor_perl/exiftool -api QuickTimeUTC -d %Y/%B '-directory<$DateTimeOriginal/' '-directory<$CreateDate/' '-FileName=%f%-c.%e' "$filename"
            echo "Found a value"
            echo "Okay its $(tput setab 22)DateTimeOriginal$(tput sgr0)"
        else
            echo "FINISH YOUR SYNTAX !!"
        fi
    fi
    

    So it’s called as ./exif_date_filter.sh /some/image.jpg

    Then, assuming you have GNU parallel installed (should be easy to find on just about every distro), you could do… uh, I think just eg. find /home/user/Pictures -type f | parallel ./exif_date_filter.sh to automagically run as many “copies” of that script at the same time as you have CPU cores