filenames

Programmatically determine maximum filename length

本秂侑毒 提交于 2019-12-22 06:23:35
问题 How can I determine the maximum filename length on a linux box? Preferred in PHP programming language. 回答1: You want pathconf or fpathconf, which are not exposed (yet) in PHP. (When they are, they'll probably be posix_pathconf .) You may also shell out to getconf, a command-line utility interface to the same functionality. Try this on your system: $ getconf NAME_MAX /tmp $ getconf PATH_MAX /tmp 回答2: there's no need to programatically determine it. it's 255 bytes. edit: you can have longer

Copy certain files from one folder to another using python

旧时模样 提交于 2019-12-22 05:37:26
问题 I am trying to copy only certain files from one folder to another. The filenames are in a attribute table of a shapefile. I am successful upto writing the filenames into a .csv file and list the column containing the list of the filenames to be transferred. I am stuck after that on how to read those filenames to copy them to another folder. I have read about using Shutil.copy/move but not sure how to use it. Any help is appreciated. Below is my script: import arcpy import csv import os import

Validate Windows filename

醉酒当歌 提交于 2019-12-21 20:22:46
问题 How do I determine whether a given string is a valid Windows filename? I'm thinking of some function that I can give a string and that returns a boolean. It should check for disallowed characters (<>:"/\|?*) and for reserved words (CON, PRN, et cetera). isValidWindowsFilename('readme.txt'); // true isValidWindowsFilename('foo/bar'); // false isValidWindowsFilename('CON'); // false I've found a MSDN reference describing exactly what is valid: http://msdn.microsoft.com/en-us/library/windows

Why the names of some css, js files have random numbers in them?

你离开我真会死。 提交于 2019-12-21 17:56:27
问题 Some websites seem to have file names such as 'assets/app-02b4523sev8fsd56e.js'. I have noticed that these numbers do not change though, so I thought it has something to do with security but I am not sure. Is there any reason behind this? 回答1: This is normally to break caches stored by the browser so that the latest version of a file is loaded. Every time a file is changed this value will normally be changed also. This can be done manually by changing the filename and/or the paths in other

Android get date and insert to filename

和自甴很熟 提交于 2019-12-21 16:50:55
问题 I am having a quite annoying problem. I want to get the current date/time and insert it into a filename but I can't for my life get it to work. I want to get the time as 2011-11-18 12:13:57 and then insert it into my filename filename-2011-11-18-12:13:57.tar.gz I have tried SimpleDateFormat etc. but it just won't work! (I am writing in Eclipse Indigo) 回答1: You can use this: import java.text.SimpleDateFormat; // ... SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss",

How to know character encoding of file names depending on the filesystem

こ雲淡風輕ζ 提交于 2019-12-21 12:27:27
问题 I would like to know the character encoding of the file names in a filesystem in order to display correctly them in a GUI. How should I do this ? I suppose I get different character encoding depending on the file system (FAT, NTFS, ext3, etc.) Thank you (I work in C++ but this topic is not language related) 回答1: NTFS is Unicode (UTF-16). exFAT is Unicode as well. Original FAT and fAT32 use OEM character set (read more on MSDN). On Linux and Unix filename may contain any bytes except NUL and

How to set NLog's fileName to the process start date?

本秂侑毒 提交于 2019-12-21 12:07:12
问题 I tried <target name="txtFile" xsi:type="File" fileName="${date:format=yyyy-MM-dd HH-mm-ss}.txt" layout="${longdate} ${level} ${message}"/> but it creates a new file each minute. I realize that there is ${processinfo:property=StartTime} but I couldn't format it. I tried: ${processinfo:property=StartTime:format=yyyy-MM-dd HH-mm-ss} but it doesn't work 回答1: Using the Cached Layout Renderer For a solution that doesn't require code, use the Cached Layout Renderer: <target name="txtFile" xsi:type=

separate real and imaginary part of a complex number in python

亡梦爱人 提交于 2019-12-21 06:58:44
问题 I have need to extract the real and imaginary elements of a complex number in python. I know how to make a list into a complex number... but not the other way around. I have this: Y = (-5.79829066331+4.55640490659j) I need: Z = (-5.79829066331, 4.55640490659) and I will also need each part if there is a way to go directly without going by way of Z: A = -5.79829066331 B = 4.55640490659 https://docs.python.org/2/library/functions.html#complex Thanks! 回答1: Y = (-5.79829066331+4.55640490659j) Z =

remove extension from file [duplicate]

本小妞迷上赌 提交于 2019-12-21 03:41:10
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How remove extension from string (only real extension!) I am brand new to php and have a lot to learn! I'm experimenting with MiniGal Nano for our King County Iris Society website. It work quite well for our purposes with one small exception: the photo file name needs to be visible under the thumbnail. I've created a work around, but it shows the extension. I've found code samples of functions but have no idea

A way to use RegEx to find a set of filenames paths in a string

岁酱吖の 提交于 2019-12-21 02:37:05
问题 Good morning guys Is there a good way to use regular expression in C# in order to find all filenames and their paths within a string variable? For example, if you have this string: string s = @"Hello John these are the files you have to send us today: <file>C:\Development\Projects 2010\Accounting\file20101130.csv</file>, <file>C:\Development\Projects 2010\Accounting\orders20101130.docx</file> also we would like you to send <file>C:\Development\Projects 2010\Accounting\customersupdated.xls<