filenames

Replacing one string in a bunch of file names with another

Every week I put up a bunch of .jpg screen captures on my project's wiki to show the difference between this week's status and last weeks. The files are called things like ProgrammerAtasks_current.jpg and ProgrammerBtasks_lastweek.jpg so there is a pair of *_current.jpg and *_lastweek.jpg for each status. Each week I delete the old *_l...

How to get file extension from string in C++

Given a string "filename.conf", how to I verify the extension part? I need a cross platform solution. ...

Batch renaming of files with international chars on Windows XP

I have a whole bunch of files with filenames using our lovely Swedish letters å å and ö. For various reasons I now need to convert these to an [a-zA-Z] range. Just removing anything outside this range is fairly easy. The thing that's causing me trouble is that I'd like to replace å with a, ö with o and so on. This is charset troubles a...

Is it the filename or the whole URL used as a key in browser caches?

It's common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches the new version instead. One solution is to embed a version number in the resource's filename, but will placing the resources to be managed in this way in a directory...

What's the (JavaScript) Regular Expression I should use to ensure a string is a valid file name?

I'm still learning RegEx at the moment, but for the time being could someone help me out with this? I have a few special requirements for formatting the string: No directories. JUST the file name. File name needs to be all lowercase. Whitespaces need to be replaced with underscores. Shouldn't be hard, but I'm pressed for time and I...

How can I write a shell script to direct grep data into a date-based filename?

I basically want to do this: grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log ...with of course the filename being example.com.2008-09-27-11:21:30.log I'd then put this in crontab to run daily. ...

Is this the best way to get unique version of filename w/ Python?

Still 'diving in' to Python, and want to make sure I'm not overlooking something. I wrote a script that extracts files from several zip files, and saves the extracted files together in one directory. To prevent duplicate filenames from being over-written, I wrote this little function - and I'm just wondering if there is a better way to d...

Any caveats to generating unique filenames for random images by running MD5 over the image contents?

I want to generate unique filenames per image so I'm using MD5 to make filenames.Since two of the same image could come from different locations, I'd like to actually base the hash on the image contents. What caveats does this present? (doing this with PHP5 for what it's worth) ...

How to rename with prefix/suffix ?

How do I do mv original.filename new.original.filename without retyping the original filename? I would imagine being able to do something like mv -p=new. original.filename or perhaps mv original.filename new.~ or whatever - but I can't see anything like this after looking at man mv / info mv pages. Of course, I could write a shell scri...

Encode URLs into safe filename string

I'm writing a simple C++ class in which I would like cache picture thumbnails versions of images downloaded from the web. As such, I would like to use a hash function which takes in URL strings and outputs a unique string suitable as a filename. Is there a simple way to do this without re-writing the function myself? I searched around...

Batch file script to remove special characters from filenames (Windows)

I have a large set of files, some of which contain special characters in the filename (e.g. ä,ö,%, and others). I'd like a script file to iterate over these files and rename them removing the special characters. I don't really mind what it does, but it could replace them with underscores for example e.g. Störung%20.doc would be renamed ...

Maximum Filename Length in NTFS (XP and Vista)?

Quick and simple question which I need the answer to. I'm designing a database table which will hold filenames of uploaded files. What is the maximum length of a filename in NTFS; aka Windows XP or Vista? Many Thanks ...

Turn a string into a valid filename in Python

I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like "_-.() ". What's the most elegant solution? The filename needs to be ...

On Windows, when should you use the "\\\\?\\" filename prefix?

I came across a c library for opening files given a Unicode filename. Before opening the file, it first converts the filename to a path by prepending "\\?\". Is there any reason to do this other than to increase the maximum number of characters allowed in the path, per this msdn article? It looks like these "\\?\" paths require the Uni...

What are the rules for file extensions in Windows and Unix?

Hi, i'm currently using File::Basename fileparse to separate out a file's directory, base file name and it's extension using something like this: my($myfile_name,$mydirectory, $file_extension) = fileparse($$rhash_params{'storage_full_path_location'},'\..{1,4}'); But see that there's a variation where you can actually provide a array o...

user defined Parameter used as part of a filename in Access

I have an access 2007 Database that outputs a report in excel format, the report is dependent on a date parameter that is chosen by the user. This parameter is selected via a textbox (text100) that has a pop up calendar. I would like to use the date in the text box(text100) as part of the filename. I am using the transferspreadsheet met...

Java sort String array of file names by their extension

I have an array of filenames and need to sort that array by the extensions of the filename. Is there an easy way to do this? ...

Howto get filename from which class was included in PHP

I understand that the question is rather hard to understand, I didn't know how to ask it better, so I'll use this code example to make things more clear: If I have the following files: test.php: <?php include('include.php'); echo myClass::myStaticFunction(); ?> include.php <?php __autoload($classname){ include_once("class/".$cl...

In Batch: Read only the filename from a variable with path and filename

I am currently looking for a way to take a variable in batch and only parse out the filename. For example, I pass my batch file a -s parameter from another application which is subsequently set to my source variable. The source file variable typically contains something like: C:\Program Files\myapp\Instance.1\Data\filetomove.ext. I ass...

How to achieve dynamic page file names in ASP.NET?

I would like my website to create search-engine-optimized links for dynamic content (instead of locating data via the querystring). So: mysite/SomeModifiableNname.aspx instead of mysite/DynamicContent.aspx?entryID=2345. Aside from a smart 404 handler that redirects requests, or a custom mime-type handler in IIS, is there a good solut...