Post B2d3FnEg3i7uQBGPD6 by foone@digipres.club
(DIR) More posts by foone@digipres.club
(DIR) Post #B2cwteBCRuJ6Eqh4aG by foone@digipres.club
2026-01-25T00:55:45Z
0 likes, 0 repeats
hmmm. I've got a bunch of files, labeled 0013.png through 0171.png, and I need to rename them to 0001.png - 0159.pngthis seems like the kind of thing that there'd be an easy oneliner way to do it, but I'm blanking on what it'd be. Any suggestions?
(DIR) Post #B2cxALkmD6kC0uIbEO by foone@digipres.club
2026-01-25T00:58:46Z
0 likes, 0 repeats
the bad python answer:import glob,os[os.rename(orig,f'{1+i:04d}.png') for (i,orig) in enumerate(glob.glob('*.png'))]
(DIR) Post #B2cxDjAXbmXNVKxcuG by lolcat@digipres.club
2026-01-25T00:59:01Z
0 likes, 0 repeats
@foone awk.The single line might be > 200 characters long.
(DIR) Post #B2cy7Uj8UTIavijZHU by foone@digipres.club
2026-01-25T01:09:28Z
0 likes, 0 repeats
my most cursed python take is that there should be an "ezpy" command that runs the rest of the arguments as a python script, with Magic Importing turned on.What's Magic Importing? Well, if at any point your python program triggers a NameError, like writing "glob.glob" without first importing glob, it does "import glob" and then continues (if glob is the name of an existing system module)
(DIR) Post #B2cyBJklEUQ63OJiDY by lackthereof@beige.party
2026-01-25T01:10:06Z
0 likes, 0 repeats
@foone I think there's a pathlib way to make that less ugly
(DIR) Post #B2cz1CE2SwjLlUkVLU by foone@digipres.club
2026-01-25T01:19:30Z
0 likes, 0 repeats
@jenniferplusplus ooh, nice
(DIR) Post #B2czufqE3XfbXo43ou by ndonegan@mastodon.ie
2026-01-25T01:29:08Z
0 likes, 0 repeats
@foone Having flashbacks to PHP's register-globals, and now I need a good stuff drink!
(DIR) Post #B2czugeZ2Nw63vcGHY by foone@digipres.club
2026-01-25T01:29:29Z
0 likes, 0 repeats
@ndonegan yeah that's why it's cursed! it's a fantastic footgun waiting to break in weird ways!
(DIR) Post #B2d0Lt2H6kh6Hhg0Jc by philip@mastodon.mallegolhansen.com
2026-01-25T01:34:25Z
0 likes, 0 repeats
@foone Very cursed. I like it.
(DIR) Post #B2d14jI0Bv6N5WPon2 by didek@101010.pl
2026-01-25T01:41:15Z
0 likes, 0 repeats
@foone Do they have to be in the same order? ðŸ¤
(DIR) Post #B2d14kIORx0cD1be2S by foone@digipres.club
2026-01-25T01:42:32Z
0 likes, 0 repeats
@didek yeah
(DIR) Post #B2d28QXPwyXQ2nx8nA by foone@digipres.club
2026-01-25T01:54:23Z
0 likes, 0 repeats
@ben nice
(DIR) Post #B2d2WQuEEYvc8S4Mvw by foone@digipres.club
2026-01-25T01:58:48Z
0 likes, 0 repeats
yes this would be very prone to errors, but it annoys me that python isn't a great language for single-linerrs from the command line, because of how it has explicit imports.
(DIR) Post #B2d2ZYNetq9ABcK66K by foone@digipres.club
2026-01-25T01:59:20Z
0 likes, 0 repeats
alternative way to implement ezpy:import every possible system module prior to running the code
(DIR) Post #B2d2dlZNnxbgFYoe6y by foone@digipres.club
2026-01-25T02:00:06Z
0 likes, 0 repeats
exercise for the reader:how do you write code that imports every possible importable module supplied with python?
(DIR) Post #B2d2gqmQtAXBHLOGTA by foone@digipres.club
2026-01-25T02:00:29Z
0 likes, 0 repeats
also how fucking slow is it? computers are fast these days but python is famously batteries-included
(DIR) Post #B2d3FnEg3i7uQBGPD6 by foone@digipres.club
2026-01-25T02:06:58Z
0 likes, 0 repeats
ez.py lives:https://digipres.club/@clayote@peoplemaking.games/115953288258623315
(DIR) Post #B2d3It8Gal57ZtjzsG by foone@digipres.club
2026-01-25T02:07:27Z
0 likes, 0 repeats
@clayote wow. simpler than I would have thought! very cool
(DIR) Post #B2d4i88e2KJjJQWAvA by foone@digipres.club
2026-01-25T02:23:16Z
0 likes, 0 repeats
and more:https://digipres.club/@clayote@peoplemaking.games/115953351199817575