Latest commit d727688
Dec 9, 2011
|Failed to load latest commit information.|
My first nontrivial program, hence the FSM rather than regex means of identifying and renaming files. Deviantart arranges the names of their files "image_name_by_artist.jpg" and sometimes has "~_by_artist-saf3244jlas.jpg" which is a trial to rename by hand. So, as of this writing, it looks for each file in its surrounding folder with _by_ in the title. It then exchanges the characters before by and after but before a period or hyphen. All the hyphens in the image name are converted into spaces. (The artist's name may have hyphens or underscores, so it wasn't safe to convert them.) It then pulls the last four characters, adding the file extension. Obviously, that's not the best way to do this. A regex to find the files would be nicer and a more aware way of handling extensions would be safer. However, it works nicely every week and has - anecdotally - a 99.5% success rate (ignoring a file name, not mangling them) which a second pass clears up.