filenames

Set mtime based on date string in filename

Given a group of files with the following naming convention: datetime_restofname.txt an example of which would be: 200906290700_somewordorphrase.txt how could I batch change the mtime of the files to match the date and time in the filename? ...

C#: How would you make a unique filename by adding a number?

I would like to create a method which takes either a filename as a string or a FileInfo and adds an incremented number to the filename if the file exists. But can't quite wrap my head around how to do this in a good way. For example, if I have this FileInfo var file = new FileInfo(@"C:\file.ext"); I would like the method to give me a...

Before-the-dot-in-a-file-name, what is it called?

After-the-dot-in-a-file-name, it is called extension. ...

PHP file uploads - Handling arabic/chinese/japanese filenames

I have a system where a user uploads documents (pdf, word) etc. The problem being, foreign users are uploading filenames in arabic, chinese, japanese and the system, being able to handle them, is adding them to the database. Where the problem arises is trying to download the files using php: $result = mysql_query($query) or die(...

Get Filename in DOS for loop

I have the following For loop in a batch file: for /R c:\test\src %%i IN (*.*) DO ( MOVE %%i C:\test\destination ECHO %%i exit ) The result of the ECHO outputs the entire file path Ex: C:\Foldername\Filename I need to ECHO out only the Filename.Is there a specific command which would give me the filename ? Thanks ! ...

Get file name from URI string in C#

I have this method for grabbing the file name from a string URI. What can I do to make it more robust? private string GetFileName(string hrefLink) { string[] parts = hrefLink.Split('/'); string fileName = ""; if (parts.Length > 0) fileName = parts[parts.Length - 1]; else fileName = hrefLink; return ...

MDI : name of file on the tab

Hi all, I have an MDI application that initially doesn't have the main window open. When you click on file and select new, it opens a new tab with the default file name on it. My application should work like this, when you click on file and select new, a dialog box comes out asking for the name of the file you want to create. After c...

Tabbed documents in Visual Studio - possible to show more detail than the file name?

I have a solution where I'm repeating various class names within three different projects (a WCF service project, a unit testing project and a BL project). Also partial classes have been used to spread these classes across multiple files. The net result is that I've got 5 different file names that are repeated across three different pro...

How do I determine the extension(s) associated with a MIME type in PHP?

Is there a quick and dirty mapping of MIME types to extensions in PHP that I can make use of? ...

Is there a cross-platform Java method to remove filename special chars?

I'm making a cross-platform application that renames files based on data retrieved online. I'd like to sanitize the Strings I took from a web API for the current platform. I know that different platforms have different file-name requirements, so I was wondering if there's a cross-platform way to do this? Edit: On Windows platforms you ...

Programmatically determine maximum filename length

How can I determine the maximum filename length on a linux box? Preferred in PHP programming language. ...

Getting the name & extension of an uploaded file using python (google app engine)

I am using a form to upload files to the google app engine and store them in the datastore. l would also like to store the original file name and extension for presentation purposes. Is there a way of retrieving this data from the post sever side or can it only be gathered client side and sent as separate fields (e.g. http://www.tinyurl...

how to manipulate strings with shell-script

This is what I used: for i in `find some -type f -name *.class` I got: some/folder/subOne/fileOne.class some/folder/subOne/fileTwo.class some/other/sub/file.class next, I would like to get rid of the "some/" for each value of $i. What command can I use? Do I HAVE to save them into a file first? Thanks ...

How do I create a temp filename in Erlang?

I need to put data in a file since my other function takes a file as input. How to I create a uniq filename in Erlang? Something like unix "tempfile", do it exist? ...

using PHP to rename files with spaces

I've got files with spaces in their names that are already on my server. I want to rename them with underscores. I've tried putting a slash before the space, and I've tried replacing the space with %20. Still PHP gives me: No such file or directory. Here's my code: $dir = './'; $dhandle = opendir($dir); $old_files = array(); if ($dhand...

What is your favorite date and time format in a file name?

This is a somewhat subjective question, and not very important in the big scheme of things, but something that yet annoys me regularly. There seems to be no self-evident way to put a timestamp in a file name. Objective issue is that timestamps in file names should be sortable. But .NET sortable date formats like "s" ("yyyy-MM-ddTHH:mm:...

Move files to directories based on first part of filename?

I have several thousand ebooks that need to be organized on a headless linux server running bash through SSH. All of the ebooks are thankfully named with one of 2 conventions. AuthorFirstName AuthorLastName - Book Title.pdf AuthorFirstName AuthorLastName - Book Series #inSeries - Book Title.pdf i.e. Andrew Weiner - Changes.pdf Allan ...

How to make an NSString path (file name) safe

Hi, I'm using very tricky fighting methods :) to make a string like 'Fi?le*/ Name' safe for using as a file name like 'File_Name'. I'm sure there is a cocoa way to convert it. And I'm sure the best place to ask is here :) Thank you! ...

What's the advantage of having an 8-letter process?

If you run Sticky Note in Windows 7,its process, is called StikyNot.exe. Several other Windows processes keep their process names under 8 letters. Why do they do that? What is the advantage? Are they just clinging to the past? Or should everybody be publishing 8-letter executables? ...

Are there any invalid linux filenames?

If I wanted to create a string which is guaranteed not to represent a filename, I could put one of the following characters in it on Windows: \ / : * ? | < > e.g. this-is-a-filename.png ?this-is-not.png Is there any way to identify a string as 'not possibly a file' on Linux? ...