Quick HTML image gallery

find . -iname '*.jpg' | sed 's/.*/<img src="&">/' > gallery.html
My take on the original: even though I like the other's use of -exec echo, sed just feels more natural. This should also be slightly easier to improve. I expanded this into a script as an exercise, which took about 35 minutes (had to look up some docs): http://bitbucket.org/kniht/nonsense/src/7c1b46488dfc/commandlinefu/quick_image_gallery.py

2
By: kniht
2010-07-04 00:50:32

3 Alternatives + Submit Alt

What Others Think

kniht, shouldn't that end with >> gallery.html so that each invocation appends to the initial result instead of overwriting it?
unixmonkey10648 · 432 weeks and 4 days ago
@unixmonkey10648: The redirection applies to all of the output of sed, which is the output of everything piped to it from find (after substitution) -- there is only one invocation. If you wanted to combine multiple directories into one gallery.html, you could do that by changing "find ." to "find some/a other/b third-directory". If you really did want to append to gallery.html, you could do that, of course, it would just be unusual.
kniht · 432 weeks and 4 days ago
Also, I kept the original's *.jpg mask, but you could change -iname to -iregex to grab multiple image types.
kniht · 432 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: