« first day (3 days earlier)      last day (2564 days later) » 

17:14
thanks for considering writing an answer to my question!
Hopefully the attempt will succeed and result in me posting an answer. :)
I'll be happy if that happens
So will I. :)
@EliahKagan I am writing an answer about achieving the main specific goals the original script appears to have been going for: (a) parsing the output of file to obtain both the path and the file type--but in a safe and reliable manner--so that file doesn't have to be run once per file, thereby somewhat improving execution speed, and (b) running the lepton JPEG compressor on each JPEG file found.
that's awesome
But lepton has some idiosyncracies, which both make such an answer seem worthwhile and make it somewhat more cumbersome to write than I had originally predicted. In particular, lepton does not accept multiple filenames, does not accept --, and I am not yet sure how it decides whether or not something is an option flag.
I wrote my script, it worked (though I'm still testing), but when I later experimented with it by adding the -verbose flag as the first command-line argument to lepton, it emptied out all my JPEG files (fortunately they were copies!) because it took -verbose to be the name of each input file and my intended input files as output files, and even though it couldn't open -verbose, it still overwrote the "output" files.
17:25
O.O omg
good to know we can't pass it an (x)arg(s)ument list
haha if that happened to me (and I hadn't copied the files for testing) I would be writing a strongly worded bug report
You could include a zero-byte file as a screenshot of the problem!
hahaha XD
Multiple file invocations can still be avoided that way during the phase when determining which files to pass to lepton, just not multiple lepton invocations. lepton does support being run as a Unix Domain Socket server, which I suspect is how Dropbox uses it as part of their cloud infrastructure. I don't know how to use it that way, though. I'm not sure that's documented yet, outside the source code.
Anyway I would consider the details of that mode of operation to be outside the scope of the particular answer I am writing.
yeah that sounds a little exotic for this context
speaking of oddly named jpgs, my dad's sent me lots to make drawings from, and he totally hasn't adopted a Unixoid style of naming files yet. I've got
James Extention (front) .JPG
SIDE [1] .JPG
etc etc
I actually find that quite interesting and might eventually post a question about it (unless you want to). But it wouldn't reasonably fit into my answer, plus the main topic of your question seems to be how to determine the type of files in a directory hierarchy and perform an action on each. Some commands support multiple path arguments and others don't, so by going into some detail about lepton, it seems to me that I am actually illustrating an important and widely applicable consideration.
17:39
Oh yes, definitely
I was interested in that tutorial and read it quite thoroughly at the time, because I have very restricted disk space on the device I normally use, and a relatively large number of images. I think I stopped reading when I read that script because I got worried about the quality of the rest of the advice...
You're talking about the magazine article with the script?
yes, sorry
That reminds me. While searching for information about lepton, I also found this other bad shell script.
In addition to the obvious problems--like the way ls is being used, the brekage that occurs with filenames that contain spaces, and how could just loop through *.jpg instead--the business with basename is particularly unnecessary since lepton automatically strips extensions and adds .lep to name its output file, when invoked with a single filename argument for an input file.
for file in $(ls $PWD/*.jpg) O.o
does basename strip extensions without the -s option?
Doesn't it just suck when you're reading stuff and you're NOT on SE and you can't edit, comment, or vote on things? XD
I do not know of any other way besides -s to make basename strip suffixes, though my recent experience is largely limited to the version in GNU coreutils.
But anyway, regarding your interest in compressing images, I don't think any of this is a reason to avoid lepton itself. I believe Dropbox uses it production for users' JPEG image files. (They developed it.) I don't think either guide is written by anyone officially affiliated with the lepton project (though I don't know anything about the magazine article's authorship).
Also, the script on the website is from a forthcoming book... which is discouraging... but the book isn't out and perhaps the scripts will be improved before the book is released.
17:56
lepton sounded good (and I like the name) and yeah hopefully they'll have some script geeky folks proofread their book :)
@Zanna Well, this is basically the situation of almost everyone who reads an SE post, too.
Low-rep and (at least on most sites) unregistered users can submit edits, but they may or may not be accepted--reviewers do not generally know whether or not technical corrections are accurate--and on Stack Overflow itself, which is the biggest and most active site, there's a strong culture against editing code to correct it, which sometimes manifests even as disapproval of code edits that are obviously correct and totally in line with what the original author wants.
I was just trying to understand what they expected basename was going to do there; I thought maybe they included the extension and it would be stripped, since $file is intended to contain things that end in .jpg (though it will probably contain all sorts of things here)
@EliahKagan ugh that's not good
@EliahKagan true :S
Actually the basename invocation syntax--not how basename is being used in that script, but how it's being called--is okay. basename abc.def .def outputs abc.
18:02
Oh I see - nice

« first day (3 days earlier)      last day (2564 days later) »