filenames

Renaming A Running Process' File Image On Windows

I have a Windows service application on Vista SP1 and I've found that users are renaming its executable file (while it's running) and then rebooting, thus causing it to fail to start on next bootup because the service manager can no longer find the exe file since it's been renamed. I seem to recall that with older versions of Windows yo...

Command to truncate all filenames at 255 characters

An NTFS directory is open in a bash shell. what command will recursively truncate all filenames in a directory to the 255 character limit required for ext3? ...

Dynamic filename for SQL Server backups?

How can you insert the date in the filename (a dynamic filename) used in a T-SQL backup script? Using SQL Enterprise Manager to create and schedule a backup job, I'd like to edit the T-SQL created to change the filename of the backed up database to be dbname_date.bak (i.e. northwind_5-1-2009.bak). The next time the backup runs, it will...

Make Django return response as a "different filename"

I have a Django view which returns an HttpResponse with a special MIME type to make the user's browser "download" the file instead of view it in the browser. The problem is that the default filename that the response will be saved as is the URL which the user tried to access. Is there any way to include a default filename in the HttpRe...

Can my file (image) names be too long?

When outputting images from Photoshop that are over 31 characters I get a compatibility message? Is there a downside to making image names (or any filenames) too long? I want to make sure my web app displays my images correctly in all major browsers, including mobile, and that my image names get picked up by Google for indexing. For ex...

Enforce File Naming Convention on Windows Share?

Hi Everyone, Simple question, but I can't seem to find the answer anywhere. Is there a way in Windows, or via a third-party utility, to enforce file naming conventions within a Windows network share? I'm sure this is easy in Sharepoint, but I want to be able to limit users to the file name format they save into a folder. I could crea...

How do I write some (bash) shell script to convert all matching filenames in directory to command-line options?

Apparently the answer to my question "Can I restrict nose coverage output to directory (rather than package)?" is no, but I can pass a --coverage-package=PACKAGE option to nose with the package name of each .py file in the directory. So for example, if the directory contains: foo.py bar.py baz.py ...then I would need to use the comma...

Unable to combine pwd with filenames in Zsh

Problem: to combine PATHs with filenames, such that I can easily source many files. I have two files A and B. ls gives their names clearly. I run pwd `ls` I get the error message too many arguments I did not find an option for pwd which would allow me to have more than one argument. How can you combine pwd's output to filenames....

Expand a relative path in Ant script, for Inkscape

I'd like to write an Ant script that calls an external utility (Inkscape, in fact) that needs a full path. Right now I have <exec executable="${inkscape.path}"> <arg value="--file=build_exe/splash.svg" /> <arg value="--export-png=build_exe/splash.png" /> <arg value="-C" /> </exec> On Windows, Inkscape requires absolute pat...

Create files using list of filenames and add content to each

I need to make a bunch of redirect pages as I've recently updated my web site which previously used .html files and now all the files are .aspx. I have a tab-delimited file containing a list of original filenames and the corresponding new filename. It seems like there should be a language out there that I should be able to create a file...

Change filename extension in basic (for OpenOffice macro)

I am trying to change a filename extension in a macro for OpenOffice. My files are named like "file.odt" and I need to transform this string to "file.pdf". I use a macro that I have found on the Web but I have never written any line of basic code in my life ... However, the code is buggy and only works for 3 chars extensions (like ".do...

Why don't files and directories have separate namespaces?

Files and directories could have different namespaces, and still be used to identify specific files, because a file and directory with the same name can be distinguished by being different kinds of things. Primitive field and reference fields could also have different namespaces (in Java), because if a primitive and a reference field ha...

How to write such a converter to change PHP file into bash file?

My so far not so bad version to implement this is: function bashFileConvert($file) { return preg_replace('/([^\/\s]+\s+[^\/]+)(\/|$)/','"${1}"${2}',$file); } which mostly processes the problem when there is a space in file name,like $flie = '/usr/local/my test file.txt' while will not be recognizable for bash, so need to conv...

How can I sanitize a string for use as a filename?

I've got a routine that converts a file into a different format and saves it. The original datafiles were numbered, but my routine gives the output a filename based on an internal name found in the original. I tried to batch-run it on a whole directory, and it worked fine until I hit one file whose internal name had a slash in it. Oop...

C#: Using Directory.GetFiles to get files with fixed length

The directory 'C:\temp' has two files named 'GZ96A7005.tif' and 'GZ96A7005001.tif'. They have different length with the same extension. Now I run below code: string[] resultFileNames = Directory.GetFiles(@"C:\temp", "????????????.tif"); The 'resultFileNames' return two items 'c:\temp\GZ96A7005.tif' and 'c:\temp\GZ96A7005001.tif'. But ...

Extract filename and extension in bash

I want to get the filename (without extension) and the extension separately. The best solution I found so far is: NAME=`echo "$FILE" | cut -d'.' -f1` EXTENSION=`echo "$FILE" | cut -d'.' -f2` This is bad because it doesn't work if the filename contains multiple "." characters. If let's say I have a.b.js it will consider a and b.js, in...

splitting a full filename into parts

I am creating a function that will split a full unix filename(like /home/earlz/test.bin) into its individual parts. I have got a function, and it works for the first two parts perfect, but after that it produces erroneous output... strlcpy_char will copy a string using term as the terminator, as well as 0. If it is terminated with term...

Get file name from a file location in Java

I have a String which provides an absolute path to a file (inlcuding the file name). I want to get just the filename. What is the easiest way to do this. It needs to be as general as possible as I cannot know in advance what the URL will be. I can't simply create a URL object and use getFile() - all though that would have been ideal if ...

C#/.NET Server Path to default/index page

In my attempt to further future-proof a project I am trying to find the best way to retrieve the full path and filename of the index/default page in a web directory using C# and without knowing the web server's list of filename possibilities. 'Server.MapPath("/test/")' gives me 'C:\www\test\' ...so does: 'Server.MapPath(Page.ResolveUrl...

C#/.NET: What is the best way to combine a path and a filename?

What is the best way to combine a path with a filename? That is, given "c:\foo" and "bar.txt", I want "c:\foo\bar.txt". Given "c:\foo" and "..\bar.txt", I want either an error or "c:\foo\bar.txt" (so I cannot use Path.Combine() directly). Similarly for 'c:\foo" and "bar/baz.txt", I want an error or "c:\foo\baz.txt" (not "c:\foo\bar\baz...