Dear reader,

This site finally got its much-needed overhaul. I tried to keep existing pages at their original URLs.
Should you find an error, please do tell me at contact@aspyct.org.
Feel free to visit the new website, which may contain more documentation pertaining to your search.

Thank you for visiting aspyct.org, I hope you'll find what you're looking for.

Old Aspyct.org blog

 or  go to the new site.

shutils to the rescue

Today I had to import about ~150 file entries into an XML file. Being a good lazy geek, I could not resign myself to copy/paste this over. With the help of Rake and some custom-tailored scripts, I made it through in no time :)

All these files had the same format:

1
2
3
4
5
chapter1_slide1_fr.png
chapter1_slide2_fr.png
...
chapter1_slide19_fr.png
chapter2_slide1_fr.png

Of course, when I tried to sort them with the sort command, it did not really work as expected… Because this is a lexicographical sort, and not the natural sort we would expect.

1
2
chapter1_slide19_fr.png
chapter1_slide1_fr.png

I needed a natural sort, just like the natsort() function from PHP. Actually, I also needed a small program that would list the contents of a directory and print its naturally-sorted contents.

These scripts are available on my github. You can easily install them for your user by running the shutil_install.sh script. You may have to chmod +x the scripts however. Read more on these scripts on their dedicated page.

Hope you’ll find this useful, feel free to contribute your own scripts (via pull requests, for example :)