Malicious enjoyment derived from observing someone else’s misfortune
 

Tag Archives: scripting

wget mirroring with external references

I was having trouble mirroring a website that had all its images hosted on a different domain, which happened to be random subdomains of cloudfront.net.  I tried adding *.cloudfront.net to the -D parameter, but that didn’t work.  It turns out it’s smart enough to figure out that all subdomains in the domain list should be included as well: wget -mkpEK -D www.allshepherdrescue.org,cloudfront.net -H -t 3 \ –restrict-file-names=windows http://www.allshepherdrescue.org/ This goes into mirror mode, changes relative links to the proper form, [...]

Finding bad JPEGs with Xorg hacks in Ubuntu

So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one: Premature end of JPEG file So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to the display the images in sequence: perl -e ‘for(glob(“*.png *.jpg”)){$output = `qiv “$_” 2>&1;`; if($output =~ /Premature/){print $_, “\n”;}}’ All this does is mix STDERR [...]

Setting EXIF dates with a loop

Magic EXIF recursive tagging! Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates? Here’s what I used today to do it: # Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg # Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU’RE DOING!) find . -mindepth 3 -exec jhead -de “{}” \; # Make Fresh EXIF tags find . -mindepth 3 -exec jhead -mkexif “{}” \; # Set the dates according [...]

Using seq to zero-pad strings in a series

I thought this was pretty cool: for i in `seq -f "%03g" 1 100`; do wget http://www.gozerog.com/images/Hawking_$i.jpg; done We were trying to do this the other night using bash, but to no avail since the square brackets only work for local file path expansion. I should have remembered seq. Also, this example shows how to 0-pad a series using seq and bash, noted by the *-f* option. Three cheers for seq!