yaydl 1.4a

It's already been more than one month since I released yaydl 1.3.7, so it's time for a small status update. The attached preview of the upcoming release already includes two main new features: support for playlists and 1080p videos on Youtube. Please note that these improvements aren't fully stable yet and might include some bugs - so if you're a fan of rock-stable software, keep your hands off this alpha ;-)

Download the tar.gz

Lyrics fetcher for moc

As the newest alpha version of moc comes with the ability to display song lyrics, I thought it might be a nice feature to fetch these lyrics automatically. So I just cobbled together a few lines perl code, that actually work pretty well. Nevertheless it's just a quick hack with a lot of bugs, so don't expect too much. :-)

Download

HowTo: Convert Windows-style line endings to Unix-style (and vice versa)

Though there are some tools (e.g. dos2unix) available to convert between DOS/Windows (\r\n) and Unix (\n) line endings, you'd sometimes like to solve this rather simple task with tools available on any linux box you connect to. So, here are some examples - just pick the one that fits you best: Windows to Unix:

#Shell
perl -pe '$_=~s#\r\n#\n#' < windows.txt [> linux.txt]
sed -r 's/\r$//' windows.txt [> linux.txt]

#Vim
:%s/\r$//
:set ff=unix

Unix to Windows (do you really want this?)

#Shell
perl -pe '$_=~s#\n#\r\n#' < linux.txt [> windows.txt]
sed -r 's/$/\r/' linux.txt [> windows.txt]

#Vim
:set ff=dos

Don't forget to save your file, when you're using vim.

yaydl 1.3.7

A new year - a new version of yaydl. Apart from the usual bugfixes, one new feature found its way into this release: From now on, yaydl has direct support for inputfiles, which renders the workaround via shell I/O redirection obsolete. As always, the commandline option for this and all other functions can be found in the readme file. ;-)

Download the tar.gz

yaydl 1.3.6

After so many people asked me to waste some more blog entries on yaydl, I eventually found some spare time to comply with their request. ;-) However, if you were expecting some fancy new features, don't get too overexcited: v1.3.6 is just another bugfix release. Yet, I'm confident I'll extend yaydl's functionality till autumn 2010. :D

Download the tar.gz

Recursive Rename

Referring to my last blog entry, I'm proud to present an enhanced version of Larry Wall's/Robin Baker's famous script (p)rename. The main difference between the original and recrename lies within the fact, that the latter recursively renames all files/folders in the directory tree, when invoked with a directory name as argument. So, here's an example how it works:

#"." represents the current directory...(more arguments are allowed)
recrename -n 's#\s+#_#g ;y#A-Z#a-z#;s#[^a-z0-9_\-.]#_#g;s#_+#_#g' .

If everything looks ok, you may omit the -n for the changes to take effect. Update: Since two programs for two very similar operations are a waste of precious disc space, I joined rename and recrename. From now on, recrename works recursively if you explicitly add -r to your command line. Furthermore, I changed the standard behaviour, so that modifications as from now on only affect basenames, even if the filename argument is a complete path, i.e. recrename 's#\s+#_#' "/home/foo/bar baz/bla blub" changes "bla blub" to bla_blub but leaves "bar baz" untouched.

Download

rename

One of the most annoying things about copying files from Windows systems on your local linux box are the strange filenames, Windows users consider to be state-of-the-art. Most of these names seem to consist solely of uppercase and special characters and of course lots of whitespaces... However, as we're running linux, the solution is just one simple command away: prename (rename on some systems), which is included in the standard Perl distribution, makes it possible:

#just pretend....
rename -n 's#\s+#_#g ;y#A-Z#a-z#;s#[^a-z0-9_\-.]#_#g;s#_+#_#g' *

#"sanitize" all filenames in the current directory if the output
#from above is ok
rename 's#\s+#_#g ;y#A-Z#a-z#;s#[^a-z0-9_\-.]#_#g;s#_+#_#g' *

BTW: This won't work out-of-the-box with find's exec-option!

Concatenate PDF files

There are several ways of concatenating multiple PDF files into one single PDF file. Unfortunately, most of these ways just don't work at all, or the resulting PDF is not what you'd expect it to be. However, there's one convenient way using ghostscript that always worked pretty well for me:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf *.pdf

Since this is a pretty complex command, we'll hide its complexity for future use: Put the code shown below into a newly created file /usr/local/bin/mkpdf

#!/bin/bash

[[ $# -lt 2 ]] && { echo "Usage: $0 output.pdf <inputfiles.pdf>" ; exit 1; }

OUTPUT="$1"
shift
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="$OUTPUT" "$@"

After setting up the appropriate file permissions (chmod 755 /usr/local/bin/mkpdf), mkpdf output.pdf <inputfiles.pdf> does exactly the same as the command mentioned above.