Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)HY
Posts 168
Comments 1.6K
First bash script, is there anyway to improve the execution speed ?
  • 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

  • It's just a difference of opinion!

    8
    Inside Star Citizen: Alpha 3.24 - Hangars and Freight
  • Well that'd be awesome, but don't sweat it! Would make my life easier if the perf on the SD was at least in the same solar system as "OK", but there's a decent chance I could use Whisky (or CrossOver) for this

  • Inside Star Citizen: Alpha 3.24 - Hangars and Freight
  • Feel like being a guinea pig for checking out how the current version of SC runs on the Deck? 😀

    But more seriously speaking I think I'll give something like Whisky a go. My laptop's decently new so if I can wrangle the emulation it might be Good Enough™ when coupled with a PS4 controller for testing things out during a free fly week

  • Inside Star Citizen: Alpha 3.24 - Hangars and Freight
  • Ah nice, thank you for the links.

    ~10fps in eg. cities sounds like it might be beyond my jank limit but hard to say how the overall perf would feel like. Hmm, I might look into trying to run it on my laptop but it's Apple ARM – I have a vague memory of seeing something like Proton / CrossOver pop up recently specifically for Apple silicon.

    I take it you've never tried running SC on the Deck?

  • Inside Star Citizen: Alpha 3.24 - Hangars and Freight
  • Not saying it’ll turn into 4k/60fps experience but it should be better.

    Mate it's a Deck, that's not in the cards anyhow 😀 some of the benefits of having been at this stuff for about 40 years now are that I'm fine with extremely potato settings etc and I have a very high tolerance for lag and jank.

    Is there any other way to test the performance without paying for a starter pack, besides free flights? Not that I mind waiting, Oct/Nov's going to arrive way faster than I'd like anyhow heh

  • me🤷irl

    cross-posted from: https://sopuli.xyz/post/15196192

    > Seriously, zero clue.

    1
    me_irl @lemmy.ml hydroptic @sopuli.xyz

    me🤷irl

    Seriously, zero clue.

    0
    Inside Star Citizen: Alpha 3.24 - Hangars and Freight
  • I'd really love to try SC out because I've been itching for something like Elite: Dangerous that's… well… not ED, but my only gaming machine is a Steam Deck and I've understood the performance isn't exactly great. Seems like SC is pretty enjoyable already even though it's very much not finished

  • First bash script, is there anyway to improve the execution speed ?
  • Ah yeah this suggestion is much better than mine. Reducing the number of calls to exiftool is probably the easiest way to speed things up, and giving it a glob instead of individual files is definitely worth trying because it can be quite a bit faster sometimes depending on what's being run

  • First bash script, is there anyway to improve the execution speed ?
  • I would assume that exiftool is where most time is spent. Spitballing here and I'm just ever so slightly drunk (shut up I know it's Thursday) so don't take me too seriously, but maybe you could parallelize this somehow?

    Something like modifying that script so that it takes a list of files as arguments (escaping might become a problem though because fucking bash) and then munges them, and then either in the shell or in another script you use eg GNU parallel to run that script on yourdir/**/*?

    edit: you'd want to check if it's easier to use cli arguments or stdin in a script being run with parallel, been a while since I used it. Could be either one is fine

  • www.businessinsider.com Marc Andreessen thinks comedy is basically dead. He believes AI could save it.

    Marc Andreessen, the cofounder of Andreessen Horowitz, said that AI could be the revival that comedy needs.

    Marc Andreessen thinks comedy is basically dead. He believes AI could save it.

    I'm not sure if I should be laughing or crying. Probably both.

    0
    Average Tuesday on NCD
  • It's like pure concentrated essence of 70's. I actually really do like it too; like I said in another comment it's not what I'd call a good movie as such, but the ridiculous camp is part of the fun for me. What's not to love about a weird-as-shit 70's dystopian scifi romp that's like Elysium on tons of LSD?

  • Average Tuesday on NCD

    13
    me_irl @lemmy.ml hydroptic @sopuli.xyz

    me🚬irl

    4

    Ooh big yawn

    4

    Sinimusta siirtymä

    Tämän on kyllä huomannut omista kokkaretutuista; yksi lähti jo sille linjalle, että sukupuolivähemmistöjen pelkkä olemassaolo on "kärjistävää" ja että lihaa syövää valkoinen hetero on kirjaimellisesti vainotuin "vähemmistö" – ihan epäironisesti. Toivoipa jo että kaikki vähemmistöt yksinkertaisesti katoaisivat jotenkin taianomaisesti, ei ilmeisesti kehdannut vielä julkisesti unelmoida mistään Endlösungista.

    Persututtuja on nykyään enää todella vähän, ei ole puolin eikä toisin ollut kauheasti intoa olla tekemisissä enää toviin, tämmönen sateenkaareva hörhö kun olen ja heillä mielipiteet olleet jo tovin sitä luokkaa että mulla ei tartteisi olla ihmisoikeuksia lainkaan

    8

    I don't remember this Disney princess

    0

    "If blaming women didn't fix your life, you just didn't blame them hard enough"

    20

    Can't argue with that logic

    Water mountains are my new favorite concept

    110

    This is unironically fine

    40

    Humans didn't invent agriculture

    111

    himbs thirsty

    17

    Thnk of the chldren

    0
    Political Memes @lemmy.world hydroptic @sopuli.xyz

    Unlike the image, I definitely encourage people to do this

    96

    I fuckin' knew it!

    6

    How can they not see this is what's coming‽

    Anybody know who the original author is?

    Author: https://www.instagram.com/adamtots/

    65

    Apex friend?

    24

    More wisdom from Supply Side Jesus

    78