In today’s chautauqua…

  • 0 Posts
  • 42 Comments
Joined 3 months ago
cake
Cake day: September 15th, 2025

help-circle
  • phaedrus@piefed.worldtoLinux@lemmy.mlBash scripting question
    link
    fedilink
    English
    arrow-up
    1
    ·
    48 minutes ago

    It might be instance related, I’m on PieFed, so perhaps the markdown implementation is different.

    Also, I realized that the parameter expansion might not be straightforward and added the GNU docs on it, but looks like you found a post about it at the same time! Glad to hear it got you sorted out.


  • phaedrus@piefed.worldtoLinux@lemmy.mlBash scripting question
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    51 minutes ago

    You can do the entire thing as a one-liner using only find:

    find ./ -type f \( -iname "*.jpg" -or -iname "*.png" \) -exec sh -c 'mv "$0" "$(uuidgen -r).${0##*.}"' {} \;  
    

    Test on my machine:

    phaedrus@sys76 ~/D/test> ls -lh  
    total 0  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test1.jpg  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test1.png  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test2.jpg  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test2.png  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test3.jpg  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 test3.png  
    phaedrus@sys76 ~/D/test> find ./ -type f \( -iname "*.jpg" -or -iname "*.png" \) -exec sh -c 'mv "$0" "$(uuidgen -r).${0##*.}"' {} \;  
    phaedrus@sys76 ~/D/test> ls -lh  
    total 0  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 062d8954-9921-42bd-ad24-0e4ed403a5db.jpg  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 111f859f-b1fe-4488-b2bc-75585320e3a3.png  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 39b9fe4e-7a05-43c9-b30a-69e9a13aa3a9.png  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 57bda91e-49e5-43fe-8318-aeeb2e3adde7.png  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 97398eb7-54aa-488f-8fbe-0b84b5e5a50d.jpg  
    -rw-r--r-- 1 phaedrus users 0 Dec  6 01:08 f7a13274-e2c0-4fa7-9907-c590d1280c2e.jpg  
    

    btw, Lemmy doesn’t like language specifiers in the multi-line code blocks, so it’s difficult to read all that in its current form since there are no tabs to know how you have it formatted. Makes it virtually impossible to troubleshoot your specific script.

    edit: further reading on the ever useful variable expansions (${0##*.} portion of my one-liner):
    https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
















  • Not OP, but I also live in the woods (albeit I’m in a 4x4 vehicle and don’t stay in one place for long periods).

    The point for me is not to, and nature is my TV. When I do need internet, though, I’m in town stocking up on supplies or hanging out in a coffee shop.

    Also, though, 5G and the abundance of towers means that hotspots work in a lot more places than they used to. More often than not, my phone still gets data even deep in the middle of nowhere. I’m not doing any gaming or streaming, but again I don’t necessarily want to. It’s just a tool to get information some times and make dumb internet comments.