Top-rated recipes tagged "filename"http://code.activestate.com/recipes/tags/filename/top/2016-03-08T05:49:16-08:00ActiveState Code Recipesslugify: make a string usable in a URL or filename (Python)
2010-06-07T04:11:55-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577257-slugify-make-a-string-usable-in-a-url-or-filename/
<p style="color: grey">
Python
recipe 577257
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/ascii/">ascii</a>, <a href="/recipes/tags/django/">django</a>, <a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/slug/">slug</a>, <a href="/recipes/tags/slugify/">slugify</a>, <a href="/recipes/tags/url/">url</a>).
Revision 2.
</p>
<p>"Slugify" a string so it is ascii, has only alphanumeric and hyphen characters. Useful for URLs and filenames. This is heavily based on the slugify in Django.</p>
<p>Note: presumes that you've <code>import re</code>d higher up in your module.</p>
FileSpec: Set it, forget it, reuse it (Python)
2016-03-08T05:49:16-08:00Jack Trainorhttp://code.activestate.com/recipes/users/4076953/http://code.activestate.com/recipes/580618-filespec-set-it-forget-it-reuse-it/
<p style="color: grey">
Python
recipe 580618
by <a href="/recipes/users/4076953/">Jack Trainor</a>
(<a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/utilities/">utilities</a>).
</p>
<p>Python provides good utilities for transforming filenames, but they are tedious to use and clutter up the source code.</p>
<p>FileSpec offers one-stop shopping to convert a file path to every component you might want to know, reuse, or transform.</p>
slugify: make a string usable in a URL or filename (JavaScript)
2011-07-12T17:46:49-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577787-slugify-make-a-string-usable-in-a-url-or-filename/
<p style="color: grey">
JavaScript
recipe 577787
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/nodejs/">nodejs</a>, <a href="/recipes/tags/slug/">slug</a>, <a href="/recipes/tags/slugify/">slugify</a>, <a href="/recipes/tags/url/">url</a>).
Revision 2.
</p>
<p>"Slugify" a string so it has only alphanumeric and hyphen characters. Useful for URLs and filenames. This is a JavaScript (node.js too) version of <a href="http://code.activestate.com/recipes/577257/">Recipe 577257</a>.</p>
<p>Note: It is missing the guarantee that only ascii characters are passed through. I don't know an NFKD equivalent in JavaScript-land.</p>
Prints full name of all occurrences of given filename in your PATH (Python)
2009-06-29T15:20:10-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/576823-prints-full-name-of-all-occurrences-of-given-filen/
<p style="color: grey">
Python
recipe 576823
by <a href="/recipes/users/4170919/">Ben Hoyt</a>
(<a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/which/">which</a>).
</p>
<p>Simple program to print the full name of all occurrences of the given filename in your PATH. Kind of like the Unix "which" utility, but works for DLLs and other files as well.</p>
<p>Usage: findinpath.py filename</p>
Case insensitive filename on *nix systems - return the correct case filename (Python)
2008-11-25T16:27:13-08:00Campbell Bartonhttp://code.activestate.com/recipes/users/4168177/http://code.activestate.com/recipes/576571-case-insensitive-filename-on-nix-systems-return-th/
<p style="color: grey">
Python
recipe 576571
by <a href="/recipes/users/4168177/">Campbell Barton</a>
(<a href="/recipes/tags/case/">case</a>, <a href="/recipes/tags/case_insensitive/">case_insensitive</a>, <a href="/recipes/tags/convert/">convert</a>, <a href="/recipes/tags/filename/">filename</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/sensitive/">sensitive</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 9.
</p>
<p>When dealing with windows paths on a *nix system sometimes youll need to resolve case insensitive paths. While using a fat filesystem or making everything lowercase would work.
this function means you can get python to take a case insensitive path and return the path with the correct case (if it exists).</p>