Questions tagged [filenames]

Filenames are metadata about a file; a string used to uniquely identify a file stored on the file system of a computer.

The filename is metadata about a file; a special kind of string used to uniquely identify a file stored on the file system of a computer. Some operating systems also identify directories in the same way. Different operating systems impose different restrictions on length and allowed characters on filenames.

4148 questions
97
votes
26 answers

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.
JeffV
  • 52,985
  • 32
  • 103
  • 124
91
votes
8 answers

How to deploy Node.js application with deep node_modules structure on Windows?

I've run into a curious issue - apparently some Node.js module have so deep folder hierarchies that Windows copy command (or PowerShell's Copy-Item which is what we're actually using) hits the infamous "path too long" error when path is over 250…
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240
81
votes
6 answers

Flutter: Get the filename of a File

I thought this would be pretty straight-forward, but can't seem to get this. I have a File file and it has a path file.path which spits out something like /storage/emulated/0/Android/data/my_app/files/Pictures/ca04f332.png but I can't seem to find…
Jus10
  • 14,519
  • 21
  • 52
  • 77
80
votes
5 answers

javascript url-safe filename-safe string

Looking for a regex/replace function to take a user inputted string say, "John Smith's Cool Page" and return a filename/url safe string like "john_smith_s_cool_page.html", or something to that extent.
ndmweb
  • 3,370
  • 6
  • 33
  • 37
77
votes
8 answers

Mac OS X doesn't allow to name files starting with a dot. How do I name the .htaccess file?

As mentioned in the title, Mac OS X doesn't allow me to name files starting with a dot ( . ). You can’t use a name that begins with a dot “.”, because these names are reserved for the system. Please choose another name. But, I need an .htaccess…
Diego Favero
  • 1,969
  • 2
  • 22
  • 32
75
votes
7 answers

How to remove files starting with double hyphen?

I have some files on my Unix machine that start with -- e.g. --testings.html If I try to remove it I get the following error: cb0$ rm --testings.html rm: illegal option -- - usage: rm [-f | -i] [-dPRrvW] file ... unlink file I tried rm…
cb0
  • 8,415
  • 9
  • 52
  • 80
75
votes
2 answers

Association between naming classes and naming their files in python (convention?)

In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter of each word, which should be a capital letter. Example: class FooBar: ... A class should go in a file,…
Aufwind
  • 25,310
  • 38
  • 109
  • 154
75
votes
7 answers

Append date to filename in linux

I want add the date next to a filename ("somefile.txt"). For example: somefile_25-11-2009.txt or somefile_25Nov2009.txt or anything to that effect Maybe a script will do or some command in the terminal window. I'm using Linux(Ubuntu). The script or…
sami
  • 867
  • 1
  • 8
  • 13
70
votes
13 answers

Create (sane/safe) filename from any (unsafe) string

I want to create a sane/safe filename (i.e. somewhat readable, no "strange" characters, etc.) from some random Unicode string (which might contain just anything). (It doesn't matter for me whether the function is Cocoa, ObjC, Python, etc.) Of…
Albert
  • 65,406
  • 61
  • 242
  • 386
68
votes
8 answers

What is the correct way to join multiple path components into a single complete path in emacs lisp?

Suppose I have variables dir and file containing strings representing a directory and a filename, respectively . What is the proper way in emacs lisp to join them into a full path to the file? For example, if dir is "/usr/bin" and file is "ls", then…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
67
votes
13 answers

Get only filename from url in php without any variable values which exist in the url

I want to get filename without any $_GET variable values from a URL in php? My URL is http://learner.com/learningphp.php?lid=1348 I only want to retrieve the learningphp.php from the URL? How to do this? I used basename() function but it gives all…
sqlchild
  • 8,754
  • 28
  • 105
  • 167
65
votes
8 answers

How to get pdf filename with Python requests?

I'm using the Python requests library to get a PDF file from the web. This works fine, but I now also want the original filename. If I go to a PDF file in Firefox and click download it already has a filename defined to save the pdf. How do I get…
kramer65
  • 50,427
  • 120
  • 308
  • 488
64
votes
8 answers

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…
Ben S
  • 68,394
  • 30
  • 171
  • 212
63
votes
6 answers

Convert URL to normal windows filename Java

Is there a way to convert this: /C:/Users/David/Dropbox/My%20Programs/Java/Test/bin/myJar.jar into this?: C:\Users\David\Dropbox\My Programs\Java\Test\bin\myJar.jar I am using the following code, which will return the full path of the .JAR…
David
  • 15,652
  • 26
  • 115
  • 156
63
votes
4 answers

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…
izb
  • 50,101
  • 39
  • 117
  • 168