filenames

How to save a file with an incrementing suffix - file1, file2, etc.

Scenario: I save my drawing with a file name as picture. After a while I made some changes on the file picture and save it again. Since both file have the same name, is it possible that the new file automatically saved as picture*1* without need to manually change the file name in the program? ... I means automatically add number at th...

UnicodeEncodeError on joining file name

It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code: filename = 'Spywaj.ttf' print repr(filename) >> 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) But the file is valid and existed on disk. Filename was extracted from "unzi...

Is there a standard DateTime string representation that is valid as a Windows file name and can be parsed using DateTime.Parse?

As part of a simple backup process, I would like to save files with the name indicating the date and time of the backup. Right now I am using yyyyMMddTHHmmss, i.e. "20100601T115720". I would like to be able to parse those dates back to allow clean up of files older than a certain date. (The backup date time is not necessary the same as t...

How to extract substring from a text file in bash?

I have lots of strings in a text file, like this: "/home/mossen/Desktop/jeff's project/Results/FCCY.png" "/tmp/accept/FLWS14UU.png" "/home/tten/Desktop/.wordi/STSMLC.png" I want to get only the file names from the string as I read the text file line by line, using a bash shell script. The file name will always end in .png and will al...

How to sort filenames with possibly unpadded numbers in c++?

I need to sort filenames that can have a common root, but are then followed by numbers that are not necessarily padded uniformely; one example is what you obtain when you rename multiple files in Windows. filenamea (1).txt filenamea (2).txt ... filenamea (10).txt ... filenamea (100).txt ... filenameb.txt ... filenamec (1).txt filenamec ...

auto display filename in a directory and auto fill it as value

Hi Guys, I want something (final) like this : <?php //named as config.php $fn[0]["long"] = "file name"; $fn[0]["short"] = "file-name.txt"; $fn[1]["long"] = "file name 1"; $fn[1]["short"] = "file-name_1.txt"; ?> What that I want to?: 1. $fn[0], $fn[1], etc.., as auto increasing 2. "file-name.txt", "file-name_1.txt", etc.., as fi...

How to get absolute paths after vpath matching in make?

I have a makefile that depending on some properties sets vpath and generates a list of source files into one variable. I need to run the makefile without compiling anything (the compilation is actually handled by a different makefile) and just see to which real files the filenames get matched depending on the vpath settings. ...

Eliminating the need for "controller" in the filename of a Zend Framework controller

How do I eliminate the need for the "Controller" suffix in the filename of a Zend Framework controller? It just gets tiresome to keep typing that suffix in when creating controllers, and meanwhile the file is already in a controllers folder so it's superfluous. For instance, by default the homepage on a site goes to "controllers/IndexCo...

Retrieving file name with Javascript (without URL?)

I need to retrieve the file name of an HTM file - the file needs to retrieve its own file name - to use in another Javascript function within the same file. So far I have - var Docname = "ESSA_CL_2009_01" var DSstem = new Spry.Data.XMLDataSet("ESSA10_DA_sourceData_19_1.xml", "ESSA_CL_2009/" + Docname + "/Item_stem"); (the Spry or AJAX...

Using relative filepaths on a portable C++ application

I am developing a portable C++ application. Development environment is Linux. I have a code that loads data from Xml file and create a object model out of it. Currently path to file is provided as /home/myuser/projectdir/xmlfilename.xml. This is problematic when I use from a different computer where the home directory name will be differ...

Python: getting filename case as stored in Windows?

Though Windows is case insensitive, it does preserve case in filenames. In Python, is there any way to get a filename with case as it is stored on the file system? E.g., in a Python program I have filename = "texas.txt", but want to know that it's actually stored "TEXAS.txt" on the file system, even if this is inconsequential for vario...

Getting Short-Filename of Command-Line Argument from Batch-File

Hi, The following command in a batch file does not work as expected/hoped:     echo %~nxs1 Here is a sample display of what I’m trying to get: C:\>type test.bat @dir /b %1 @echo %~nxs1 C:\>test "C:\Documents and Settings\All Users\ntuser.dat" ntuser.dat NTUSER.DAT C:\>test "C:\Documents and Settings\All Users\ntuser.data" ntuser.d...

Get filename of source JSP file (even if included)

I am trying to do some debugging of JSP files that include multiple levels of nested includes. e.g. foo.jsp <%@ include file="bar.jsp"%> bar.jsp <%@ include file="baz.jsp"%> baz.jsp <%@ include file="boz.jsp"%> To help determine where a certain file is actually included I placed a simple line to output a javascrip...

How should I format user uploaded pictures' filenames?

My website deals with pictures that users upload. I'm kind of conflicted on what my picture filename should consist of. I'm worried about scalability simply and possibly security? Maybe someone out there deals with the same thing and can tell me what their use on their site? Currently, my filename convention is {pictureId}_{userId}_{sa...

os.path.join() in Qt?

I'm looking for an easy, cross platform way to join path, directory and file names into a complete path in C++. I know python has os.path.join() and matlab has fullfile(). Does Qt has something similar? QFileInfo doesn't seem to be able to do this. ...

Get parameters of .js file

Hello, I have a javascript file that I reference in HTML with standard <script src="foo.js?param"></script>. In the file I want to distinguish e.g. loading the file with foo.js from foo.js?auto and foo.js?noauto=true, but not if the file is renamed to bar.js and referenced with the same parameter. How can I accomplish this, preferably n...

C# .cs file name and class name need to be matched?

In Java the file name must be the public class name defined in that java file. Does C# has similar requirement? can I have a A.cs file which only defines a public Class B inside? thanks, ...

Fastest hash function(ASP.NET) for hashing filenames

I'm trying to optimize my ASP.NET thumbnailing script, so it doesn't resize all the images all the time, and one part of the problem is choosing the hash function for the thumbnail naming/checking procedure. Is crc32 up to the task - I'm asking cause the input data is small(only relative path, size and date)? ...

Need help tweaking regex for filenames with dimensions

I have a lot of movies in directories with filenames containing their dimensions. descriptor-800x600.mov cool_animation-720p.mp4 reactor-1080p.mov test-640x480.mov I'm looking to pull out the 800, 600 from #1. 720 from #2, 1080 from #3, etc. Looking for some help to tweak what I've got so far: $re = '/^(.*?)\-(\d{3,4})p+|(\d{2,...

File name? Path name? Base name? Naming standard for pieces of a path.

I keep getting myself in knots when I am manipulation paths and file names, because I don't have a common naming system that I use. I need to come up with a naming standard and stick to it, and I would like to be clear and consistent with others, so I am opening up to learn the canonical answers. Consider this toy problem: (Windows exa...