filenames

How to rename a file on sdcard with Android application?

家住魔仙堡 提交于 2019-12-17 06:43:18
问题 In my Android application, I want to rename the file name at runtime. How can I do it? This is my code: String[] command = {" mv", "sun moon.jpg"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo(File f) method but it does not work. 回答1: I would recommend using File.renameTo() rather than running the mv command, since I'm fairly sure the latter isn't supported..

How to rename with prefix/suffix?

房东的猫 提交于 2019-12-17 04:43:45
问题 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 script to do this, but isn't there an existing command/flag for it? 回答1: In Bash and zsh you can do this with Brace Expansion. This simply expands a list of items

Get file name from URI string in C#

北城余情 提交于 2019-12-17 04:16:48
问题 I have this method for grabbing the file name from a string URI. What can I do to make it more robust? private string GetFileName(string hrefLink) { string[] parts = hrefLink.Split('/'); string fileName = ""; if (parts.Length > 0) fileName = parts[parts.Length - 1]; else fileName = hrefLink; return fileName; } 回答1: You can just make a System.Uri object, and use IsFile to verify it's a file, then Uri.LocalPath to extract the filename. This is much safer, as it provides you a means to check the

Log4net rolling daily filename with date in the file name

别说谁变了你拦得住时间么 提交于 2019-12-17 03:51:25
问题 I would like to have files named for example: dd.mm.yyyy.log How is this possible with log4net? 回答1: In your Log4net config file, use the following parameter with the RollingFileAppender: <param name="DatePattern" value="dd.MM.yyyy'.log'" /> 回答2: <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/> <file value="logs\" /> <datePattern value="dd.MM.yyyy'.log'" /> <staticLogFileName value="false" />

Adding Local Filenames/References To Array In Actionscript

一个人想着一个人 提交于 2019-12-14 04:01:58
问题 how can i cycle thru a local folder to add all (or some) files names and references to that file in an array using actionscript 3.0? var fileArray:Array = new Array(); for (var item:Object in "../myFolder/") { trace(item.name); fileArray.push(item); } something like this? 回答1: You can only access the file system using AIR :/, or by having Flex make an HTTP call to a server-side language like ruby/python/php and having it return that information. Here is an AIR Directory Listing Example (you

Simple ZSH function and files with spaces in their name

血红的双手。 提交于 2019-12-14 03:59:00
问题 I have put the following function into my ~/.zshrc file: function note() { vim $HOME/Dropbox/$1.md } When I call it with note "20150209-132501-Recx-new note today.md" for example it creates a new file but with the file name "20150209-132501-Recx-new". I realise this is a simple question but how do I get it to create the note with the full name? 回答1: The shell performs parameter substitution and word-splitting in this order. This means you eventually execute vim /home/username/Dropbox/20150209

Invalid characters in a filename on Windows?

穿精又带淫゛_ 提交于 2019-12-14 03:43:44
问题 As per the MSDN , the following characters cannot be part of the file name: Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following: ◦The following reserved characters: < (less than) > (greater than) : (colon) " (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? (question mark) * (asterisk) In .net an api is provided to find the what are the characters not

create folders based on a file name and move those files into that folder

眉间皱痕 提交于 2019-12-14 03:22:05
问题 I am a novice in creating automated tasks. I need to create folders based on a file name and move those files into that folder. There are instructions, but I am a little scared to try...little help? 回答1: Split this into two steps (assume using C++ in Windows OS): Create a folder. #include <Windows.h> void create_folder(char* Path) { char DirName[256]; char* p = Path; char* q = DirName; while(*p) { if (('\\' == *p) || ('/' == *p)) { if (':' != *(p-1)) { CreateDirectory(DirName, NULL); } } *q++

Python 2.7: Read file with Chinese characters

ぐ巨炮叔叔 提交于 2019-12-14 03:15:36
问题 I am trying to analyze data within CSV files with Chinese characters in their names (E.g. "粗1 25g"). I am using Tkinter to choose the files like so: selectedFiles = askopenfilenames(filetypes=[("xlsx","*"),("xls","*")]) # Utilize Tkinker dialog window to choose files selectedFiles = master.tk.splitlist(selectedFiles) # Create list from files chosen I have attempted to convert the filename to unicode in this way: selectedFiles = [x.decode("utf-8") for x in selectedFiles] Only to yield the

File moving according to substring derived from file name

拟墨画扇 提交于 2019-12-14 01:14:03
问题 Ihave started a simple script in order to move files of a certain prefix to a folder of the same name eg: W100_11.jpg W100_12.jpg in to folder W100. Thanks to help from the answers below I have progressed and have a successful loop which can iterate through the file sin the folder, I am having issues with the -filter switch and when trying to use the move-item cmdlet I am getting errors The current code is: $sourceDir = read-host "Please enter source Dir:" $format = read-host "Format to look