00:10:12 Two hours later, and it has written out about one quarter of the bundle... :-| 00:28:48 aww 00:29:00 I've managed to write three shell scripts to automate the *rest* of my process 00:29:06 Nice! 00:29:16 though I still need to figure out how to reduce the resulting file size 00:29:28 the final file is a massive pdf, lol 00:29:33 starting from some pngs 00:48:10 (converting to jpgs before pdf shrinks the size nicely) 01:22:07 This repo bundle is killing my disk. :-| 01:32:45 git is reading ~100 MB/s and writing ~200 kB/s. Yeah, that'll take a while... 01:33:16 On an HDD, as well. 01:33:18 This sucks. 02:09:15 Can't even TSTP/STOP it either because it's stuck on disk I/O. 02:09:50 Well, good to know I guess. 02:43:31 * Doranwen frowns at puzzle she is stuck on 02:43:43 I've got a script to auto-crop a whole batch of pics 02:43:47 and that works fie 02:43:49 *fine 02:44:18 but I'm realizing the part I want to crop actually shifts position over the course of the set of pics 02:44:25 about 1 pixel every 5 pics 02:45:20 I'm quite happy with the shell script to crop, but I don't know how to set up in the shell script to set an iteration number to loop over for each pic it crops, and actually modify the crop parameters any time it lands on one divisible by 5 02:46:31 for the last one I ran (I edit it to change the parameters for each batch I'm cropping): https://paste.ee/p/rLKtT 02:47:43 I'd basically be adjusting the 456 number upwards every 5 pics it crops 02:49:22 Bash can do basic arithmetic. It's called 'shell arithmetic' in the official documentation I think. You'd have to implement a counter yourself though. 02:51:20 ^ Are you talking about numbers on the image file names or just counting? 02:51:45 well, there ARE numbers on the image file names, but the counting is all I mean 02:51:47 Oh right, if the files are numbered anyway, that would work. 02:52:06 the files are indeed numbered starting with 1 02:52:31 well, there's textbitoffilename-1.png 02:52:43 but same idea - the part before the numbers is absolutely identical and consistent 02:53:54 I don't think I know what to search for to find useful results for this 02:54:16 if I go the counter route, I can use that - I didn't know to call it a counter till you said that, that helped me find something 02:54:24 but if it's easier to use the file names… 02:54:55 Doranwen: `list=(*.png); len="${#list[@]}"; for (( i=0; i<$len; i++ )); do somethingwith $i; somethingwith ${list[$i]}; done` 02:55:30 * Doranwen studies command to try to understand it all 02:55:52 https://www.gnu.org/software/bash/manual/html_node/Arrays.html 02:56:14 If they're numbered like that without padding zeros, note that the order won't be right. 02:56:26 oh, I can add padding zeros, I was doing that already with pyrenamer 02:56:36 but that can happen at any stage 02:56:42 so I didn't know if I should do that before or after the cropping 02:56:53 (well, any stage *before* the pdf one) 02:57:08 they start out without the zeros, I add them in 02:57:12 so I can do that before cropping 02:57:54 If you have padding zeros and you use the filenames for arithmetic, you need to be careful with the numeric base as numbers starting with a zero will be treated as octal by default. I got bitten by that recently when I was doing some nasty date calculation in Bash. 02:58:09 yeah, I saw something about that on a Stack Overflow post just a few min ago 02:58:46 (but the counter mechanism i describe above won't have this problem; you can safely use $i as a number) 02:59:02 JAA: "If that's an issue, you can do: if (( 10#$number % 5 == 0 )) to force $number to be interpreted as base 10 (instead of base 8/octal implied by the leading zero)." 02:59:20 Yep :-) 02:59:25 smart solution, lol 02:59:52 And yeah, the counter will not be padded. 03:00:00 anyway, I need to go read that arrays link to try to understand all of this 03:00:05 I only half-understand the command 03:02:33 basically, expand the glob '*.png' and load the results into an array (this is guaranteed to be lexicographic); get the length of the array; create an index variable i and loop from i = 0 to i = length, with access in the body of the loop to both i (the index) and array[i] (the value of the array at that index) 03:03:07 the man page i linked should cover all the relevant syntax 03:03:19 it's … a bit over my head, though I'm trying valiantly ;) 03:03:47 the one thing I definitely have a question about is, do I need to remove the non-numeric part of the filenames? 03:03:52 nope 03:03:58 didn't think so, from your explanation 03:04:08 it's taking the filenames as the list 03:04:13 and then counting how many it's got in the list 03:04:15 basically 03:04:22 exactly 03:04:22 ? 03:04:27 excellent, I'm glad I'm following that 03:04:50 so as long as the full filenames sort in the order that you want, you're good 03:05:15 ok, so the next challenge is - how do I *change* the parameters on the crop every 5 pics, lol 03:05:22 because that's the whole idea here 03:06:11 the first five pics would be cropped with 1005x827+456+166, the next five with 1005x827+457+166, the next five with 1005x827+458+166, and so on 03:07:12 I had it all in `for f in *.png; do convert "$f" -crop 1005x827+456+166 +repage ../cropped/"$f"; done` which worked nicely but didn't adjust for the shifting center 03:09:05 set a margin variable, update it in the body of the loop (using $i), and then convert with `-crop 1005x827+"$margin"+166` 03:09:35 ooh, THAT's how I set it in there, ok 03:09:49 it'll take me a bit to figure that out, but I think I can do it 03:11:59 `margin=455` outside the loop, and then inside `if ! (($i % 5}}; then ((margin++)); fi`, if i recall my arithmetic syntax correctly... 03:12:37 why 455? 03:12:45 oh, because the first is 0 03:12:48 and 0 is divisible by 5? 03:13:09 so it automatically starts by adding 1 03:13:19 yeah 03:14:46 right now I'm stuck on the loops - am I not using the "for f in *.png" bit then, and if not, how am I telling it to grab each png in turn? there's some piece of this that's not clear 03:14:53 and I'll probably go "duh" when I see it 03:15:06 ^ lol that's wrong, should be `(($i % 5))`. typo 03:15:13 but right now it's that general structure that's baffling me 03:15:38 (noted) 03:15:54 `list=(*.png)` expands the glob '*.png' and stores the results in the array 'list' 03:16:23 oh right, so I can call that somehow to pass it each filename? 03:17:05 well, my "it" was unclear 03:17:42 yes, `${list[$i]}` is the item at position $i in the list (so, the $ith filename) 03:18:45 you can pass it to `convert` just as you would `$f` 03:19:29 ah! ok 03:19:48 (sorry, I really did try to read that page, but I was understanding very little of it) 03:27:41 I *think* I have it, but I'm just reading over it all 03:27:57 the only part I'm trying to understand still, how it works, are the bits inside the for (( )) 03:28:11 setting the index to 0 to start, yes? 03:28:33 and saying run as long as it's less than the last file? 03:28:54 (though does that mean it won't run when it gets to the final file?) 03:29:30 the pages on for don't have any examples with multiple things inside there like that, so I'm not sure how they all work or why 03:32:02 the `for (( i=0; i<$len; i++ ))` bit 03:32:27 * Doranwen understands each of those separately but is having trouble understanding how it all fits in and functions in the overall process 03:41:42 That is a syntax you will find in many programming languages. 03:41:52 it does work, though - I tested by setting the actual convert line to echo first, just to see, and yup, it worked 03:42:00 It's `for (( start; condition; action ))`. 03:42:10 ah 03:42:11 `start` is executed at the beginning of the loop. 03:42:21 `action` is executed after every completion of the loop body. 03:42:25 aha! 03:42:33 thank you 03:42:44 these little things are the things I find that are the hardest to find info on, lol 03:42:50 And `condition` is the check that is run before the execution of the loop body to check whether it should still be looping. 03:42:54 but they make so many other things make sense 03:43:02 ahhh, ok 03:43:06 now I understand it all 03:43:43 So here, it starts with `i=0`, then increments the value after every iteration (`i++`), and keeps doing that until `i<$len` is no longer true, i.e. until i is equal to or greater than $len. 03:44:12 Which means it iterates over all indices of the array. 03:46:12 yep 03:46:16 yay, I understand it all 03:46:30 I knew if I kept hanging around you guys I'd start picking stuff up ;) 03:47:01 I appreciate the help greatly - I've got so much more of a framework now to hang more stuff on 03:47:46 Another useful thing when working with arrays is `for value in "${array[@]}"; do ... done`. That iterates over all values in the array (but doesn't get you the nice counter variable, so it's useless in this specific case). 03:48:18 * Doranwen nods 03:49:31 But there's also ${!array[@]}, which are the indices. In this case, `for i in ${!list[@]}` would be identical to the loop we discussed above. 04:29:08 JAA: is there an easy way to run a command on a range of files *within* that selection? 04:29:26 the only methods I'm seeing operate on all the files in the folder 04:29:43 but what if I wanted to, say, run a script on just files 177-185 04:30:17 all inclusive and every number in that range counting, but not on 1-176 04:30:22 I mean, I could just move out the other files, lol 04:30:25 and then move them back 04:30:33 but there's probably a way of specifying 04:30:44 I'm not seeing anything like that in the for loop pages I'm looking at 04:30:50 but I probably just don't know what to search for 04:35:16 oh wait, just set i to 176, lol 04:35:20 in this case you could do sth like `for (( i=177; i<186; i++ )) do somethingwith restoffilename-"$i".ext; done` 04:35:22 yeh 04:35:23 er, 177 04:35:30 yeah, it just occurred to me 04:37:40 no, 176 - it didn't apply it to 177 with that last attempt, only 178 onward, interesting 04:38:15 * Doranwen scratches head 04:38:49 yeah, that definitely was it 04:38:50 Ah yes, one of the two most common issues in computer science: naming things, caching, and off-by-one errors. :-) 04:38:56 lol 04:39:05 You said your files are numbered starting from one, but the array indices start from zero. 04:39:17 RIGHT, I forgot about that 04:40:05 I'd originally thought 176 and then figured 177 because thuban said it, lol - wasn't sure exactly why I'd thought 176, but now I guess I know 04:41:28 my suggestion just substituted i directly into the filename; i thought you were doing a new thing rather than still using the array access 04:42:24 ah 04:42:28 I just copied the code and modified it 04:42:33 from the last script 04:43:56 (btw, for more general-purpose selections you can use `vipe`--puts an interactive editor into a pipeline, so you can e.g. pipe `ls` into it, manually delete the stuff you don't want, and pipe the result out into other commands) 04:47:48 TIL. Does it default to vi though? Exiting that isn't straightforward. ;-) 04:48:54 i've never gotten that joke. if it were ed... 04:49:59 (EDITOR/VISUAL, so one presumes) 04:50:33 Lots of people struggle with vi. It takes a bit of time to get used to how it works. 04:50:50 And yeah, it uses /usr/bin/editor, EDITOR, and VISUAL with fallback to vi, at least on Debian. 04:51:40 i suppose on an old enough system it could instead be ed! "Note the consistent user interface and error reportage." 05:19:26 I've used vi some, but I always have to look up the commands before I do because I don't do it often enough to remember them, lol 05:20:22 I never bothered with vi. The only thing I know is: :q! 05:20:24 :-) 05:21:31 For manual edits, I generally use nano. For anything else, I use awk/sed/grep/whatever as appropriate. 06:15:37 Oh yeah, the chromium git bundling finished after almost 9 hours. 06:27:27 lol 12:26:37 9 hours? wow 13:06:46 The chromium repo is well known to be a... big one 13:07:01 How fat was the result file? 19:08:28 there are several ephemeral resources related to the buying and selling of cars. dealers might post a carfax for a given vin, but it'll disappear after it's sold, for example. There's limited public info for license plate->vin on sites like faxvin.com and vincheck.info but you need to search a specific plate to pull the info. 19:08:42 it's mostly just boring stuff, but it might be a neat thing to try to archive. Thoughts? 19:10:22 masterX244: 22 GiB or something like that. 23:08:34 programmerq: That's -bs material