file-extension

Extract file extension from file path

☆樱花仙子☆ 提交于 2019-11-29 00:52:55
How can I extract the extension of a file given a file path as a character? I know I can do this via regular expression regexpr("\\.([[:alnum:]]+)$", x) , but wondering if there's a built-in function to deal with this? This is the sort of thing that easily found with R basic tools. E.g.: ??path. Anyway, load the tools package and read ?file_ext . Let me extend a little bit great answer from https://stackoverflow.com/users/680068/zx8754 Here is the simple code snippet # 1. Load library 'tools' library("tools") # 2. Get extension for file 'test.txt' file_ext("test.txt") The result should be 'txt

how to create a custom file extension in C#?

我怕爱的太早我们不能终老 提交于 2019-11-28 22:02:09
I need help in how to create a custom file extension in my C# app. I created a basic notes management app. Right now I'm saving my notes as .rtf (note1.rtf). I want to be able to create a file extension that only my app understands (like, note.not, maybe) File extensions are an arbitrary choice for your formats, and it's only really dependent on your application registering a certain file extension as a file of a certain type in Windows, upon installation. Coming up with your own file format usually means you save that format using a format that only your application can parse. It can either

Creating my own file extension based on plist

て烟熏妆下的殇ゞ 提交于 2019-11-28 20:51:54
My application handles with files of type *.mndl which is not more than a customized *.plist . Up until now I've been using *.plist files but now I want to associate the extension and be able to open *.mndl files from any other app I have realized that renaming file.plist to file.mndl does not work. (Hence, I don't even know if I did correctly the extension association and exportation thing) I sent to myself a file file.mndl from the computer and when received in mail.app I got file.mndl.plist (It was automatically renamed, this happened when reseting my iPad) How can I create my own mndl

Convert all file extensions to lower-case

纵然是瞬间 提交于 2019-11-28 16:05:42
I'm trying to lower-case all my extensions regardless of what it is. So far, from what I've seen, you have to specify what file extensions you want to convert to lower-case. However, I just want to lower-case everything after the first last dot . in the name. How can I do that in bash ? Igor Chubin Solution You can solve the task in one line: find . -name '*.*' -exec sh -c ' a=$(echo "$0" | sed -r "s/([^.]*)\$/\L\1/"); [ "$a" != "$0" ] && mv "$0" "$a" ' {} \; Note: this will break for filenames that contain newlines. But bear with me for now. Example of usage $ mkdir C; touch 1.TXT a.TXT B.TXT

Changing file extensions for all files in a directory on OS X

岁酱吖の 提交于 2019-11-28 15:58:29
问题 I have a directory full of files with one extension (.txt in this case) that I want to automatically convert to another extension (.md). Is there an easy terminal one-liner I can use to convert all of the files in this directory to a different file extension? Or do I need to write a script with a regular expression? 回答1: You could use something like this: for old in *.txt; do mv $old `basename $old .txt`.md; done Make a copy first! 回答2: Alternatively, you could install the ren (rename)

What is phtml, and when should I use a .phtml extension rather than .php?

走远了吗. 提交于 2019-11-28 15:10:18
I'm wondering what the difference between .phtml and .php files is, and when to use one over the other. Alex There is usually no difference, as far as page rendering goes. It's a huge facility developer-side, though, when your web project grows bigger. I make use of both in this fashion: .PHP Page doesn't contain view-related code .PHTML Page contains little (if any) data logic and the most part of it is presentation-related .phtml was the standard file extension for PHP 2 programs. .php3 took over for PHP 3. When PHP 4 came out they switched to a straight .php . The older file extensions are

.htm vs .html [closed]

时光毁灭记忆、已成空白 提交于 2019-11-28 14:58:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Which extension should I choose for my HTML files and why? 回答1: The short answer There is none. They are exactly the same. The long answer Both .htm and .html are exactly the same and will work in the same way. The choice is down to personal preference, provided you’re

Associate file type with Java Swing application

纵饮孤独 提交于 2019-11-28 12:22:30
I am creating a java swing application and I need to set the my program as the default program for the file extension .mcsd (MIME type text/mcsd ). This must work on windows, and it would be nice if it worked on OS X/Linux as well. I am somewhat new to java (3 or 4 months) so please don't bombard me with all kinds of expert talk. I have seen associating a custom file extension with java app in windows , but I would prefer not to use the Java Web Start. If possible, I would also like to know how to set the icon of that file type. I have found exe4j as a way of creating the .exe and plan to use

Apache2 server mime types

女生的网名这么多〃 提交于 2019-11-28 11:31:21
I am trying to get my Apache2 web application to push an arbitrary file extension as an octet-stream when pointed to by a browser. i.e. Someone goes to blahblah/examples/example1.xyz I want the browser to download the .xyz file rather than just display it. I have tried adding .htaccess in the root of the web app including AddType application/octet-stream xyz And I have also tried to add the mime type to /etc/apache2/mods-enabled/mime.conf and /etc/mime.types which is referenced as the types library from mime.conf . I have read a good deal about this on the internet and still haven't gotten

How to get list of all files with ESY extension in a directory?

…衆ロ難τιáo~ 提交于 2019-11-28 10:57:41
In VBA, how do I get a list of all the files with a specific extension in a specific directory? i am unable to do Application.FileSearch , because i am using excel 2007 In response to your comment "so how many times do i know to run it?" , this example runs until it lists all the files whose names match strPattern . Change the strFolder constant. Public Sub ListESY() Const strFolder As String = "C:\SomeFolder\" Const strPattern As String = "*.ESY" Dim strFile As String strFile = Dir(strFolder & strPattern, vbNormal) Do While Len(strFile) > 0 Debug.Print strFile '<- view this in Immediate