filenames

Extract files with invalid characters in filename with Python

I use python's zipfile module to extract a .zip archive (Let's take this file at http://img.dafont.com/dl/?f=akvaleir for example.) f = zipfile.ZipFile('akvaleir.zip', 'r') for fileinfo in f.infolist(): print fileinfo.filename f.extract(fileinfo, '.') Its output: Akval�ir_Normal_v2007.ttf Akval�ir, La police - The Font - Fr -...

How was a URL like http://stackoverflow.com/posts/1807421/edit created in PHP?

When you edit a question on stackoverflow.com, you will be redirected to a URL like this: http://stackoverflow.com/posts/1807421/edit But usually, it should be http://stackoverflow.com/posts/1807491/edit.php or http://stackoverflow.com/posts/edit.php?id=1807491 How was http://stackoverflow.com/posts/1807421/edit ...

ASP.NET: Get Page's filename

I have an ASPX page named Default.aspx. From its codebehind on Page_Load(), I would like to get "Default.aspx", alone, into a string: protected void Page_Load(object sender, EventArgs e) { string aspxFileName = ?; } What should I replace ? withwhat will get me the ASPX filename? ...

How do I resolve a canonical filename in Windows?

If I have a string that resolves to a file path in Windows, is there an accepted way to get a canonical form of the file name? For example, I'd like to know whether C:\stuff\things\etc\misc\whatever.txt and C:\stuff\things\etc\misc\other\..\whatever.txt actually point to the same file or not, and store the canonical form of the ...

Regular expression to remove a file's extension

I am in need of a regular expression that can remove the extension of a filename, returning only the name of the file. Here are some examples of inputs and outputs: myfile.png -> myfile myfile.png.jpg -> myfile.png I can obviously do this manually (ie removing everything from the last dot) but I'm sure that there is a regular exp...

Tab-completion of filenames as arguments for MATLAB scripts

We all know MATLAB provides tab-completion for filenames used as arguments in MATLAB function like importdata,imread. How do we do that for the functions we create? EDIT: Displays the files and folders in the current directory. ...

Reverse of os.path.normcase on Windows

Is there a simple way to get the "real" case sensitive path from a all lower case path. Like the reverse of os.path.normcase. For example, consider the directory: c:\StackOverFlow If I have the following snippet, how to obtain d_real? >>> import os >>> d = os.path.normcase('C:\\StackOverFlow') # convert to lower case >>> d 'c:\\stac...

How to include specific filename from multiple directories using PHP

Hello, I'm trying to include specific 'admin view' files from within a folder structure. I'm familiar with include/require or how to recursively include a folder, but all I need to do is include one filename from each directory - the admin_view.php file. So, my dir. structure looks like this: File to have includes is at root. - mods ...

C# - Easiest way to parse filename with spaces eg. "C:\Test\File with spaces.txt"

I am trying to pass a full file path to FFMPEG. C:\TestFolder\Input\Friends - Season 6 - Gag Reel.avi and it's obviously not liking the fact the path has spaces in it, erroring like so: C:\TestFolder\Input\Friends: no such file or directory So what's the easiest way to use filenames with spaces in them? Should I just replace all ...

Safe/Allowed filename cleaner for .NET

Is there any standardized / libraried / tested way in .NET to to take an arbitrary string and mangle it in such a way that it represents a valid file name? Rolling my own char-replace function is easy enough, but I'd like something a little more robust and resued. ...

Are there any naming conventions when creating your own file suffix?

I'm working on a little game and figured I'd pack images and other resources into my own files to keep the directories neat. Then I thought, is there any convention to what I should call my file, or can I simply call it what ever without anyone ever caring? There's probably not a lot of strong opinions about this rather innocent subject,...

NSIS:Problem when moving the files from one folder to another folder.

I have a folder containing files which will be having chinese names. When I am trying to use MoveFolder it's not moving the folder it's failing. Can anybody know the reason? Thanks in Advance, Trivikram ...

Is there an "escape converter" for file and directory names available?

Hi script-writers, The day came when I had to write a BASH script that walks arbitrary directory trees and looks at arbitrary files and attempts to determine something regarding a comparison among them. I thought it would be a simple couple-of-hours_tops!_ process - Not So! My hangup is that sometimes some idiot -ahem!- excuse me, _lov...

Flex: Get self SWF file name?

Is there a way I can programmatically determine the filename of the .swf my class is running in? Thanks! ...

Visual C++ 2008 Express - cpp filename conflict

I'm developing application for GNU/Linux using gcc 4 and cmake to manage compilation process. I found that is has no problems when there are two files with the same name but in other directory and namespace like this: . |-- gfx | |-- Object.cpp | `-- Object.h `-- logic |-- Object.cpp `-- Object.h First Object...

Export to word with a filename doesn't seem to work

I export a datatable to word, when I pass a file name it doesn't seem to get the file name in Open/Save dialog box. Here is what I am doing public static void Convertword(DataTable dt, HttpResponse Response,string filename) { try { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=...

CAT.NET "Sanitize the file path prior to passing it to file system routines" message

Hi. I'm analyzing my code (C#, desktop application) with CAT.NET Code Analysis and getting "Sanitize the file path prior to passing it to file system routines" message when dealing with file names. What I don't understand is that to ensure the file name is valid, I use: void SomeMethod(String filename) { filename = System.IO.Path.Ge...

How to swap filenames in Unix?

Any way to do this quickly without using a temp variable? Is there a built in function? Edit: Thanks for the answers guys. Looks like I need to clarify my question but for the most part you guys assumed correctly: There are two files and the filenames names are reversed. File A has name B-name.file File B has name A-name.file I'd l...

TortoiseSVN checkout problem in Windows

The problem is that I'm checking out some files with special characters in their filenames -- when TortoiseSVN attempts to check the code out, it can't create those files and the checkout fails. this applies to updating as well. Is there any fix/workaround to this, maybe to give an alternate filename or something? Update: Apparently, t...

Django FILES upload: path and filename

When an uploaded file is received by the Django server, its name can be read using UploadedFile.name If filename in the multipart-data content contains a path like: '/a/b/c', UploadedFile.name seems to contain '/c' . How can I retrieve the full path and not just the file name. Thanks. Laurent Luce ...