filenames

Listing files in date order with spaces in filenames

ぐ巨炮叔叔 提交于 2019-12-17 20:16:40
问题 I am starting with a file containing a list of hundreds of files (full paths) in a random order. I would like to list the details of the ten latest files in that list. This is my naive attempt: $ ls -las -t `cat list-of-files.txt` | head -10 That works, so long as none of the files have spaces in, but fails if they do as those files are split up at the spaces and treated as separate files. File "hello world" gives me: ls: hello: No such file or directory ls: world: No such file or directory I

What does “?”, used after JavaScript filename, means?

自闭症网瘾萝莉.ら 提交于 2019-12-17 19:34:27
问题 For example, having: <script type="text/javascript" src="http://somedomain.com/js/somejs.js?14"> </script> So what does "?14" means here? 回答1: Its a url param like any other parameter passed in a url. Sometimes JS scripts are created on the fly using server side technologies other times it is simply a version number to help with browser caching issues. 回答2: They are there to fool browsers into thinking that it is a new file. This is a trick to avoid browser-cached copy when you update the JS

Create new file but add number if filename already exists in bash

假装没事ソ 提交于 2019-12-17 18:48:11
问题 I found similar questions but not in Linux/Bash I want my script to create a file with a given name (via user input) but add number at the end if filename already exists. Example: $ create somefile Created "somefile.ext" $ create somefile Created "somefile-2.ext" 回答1: The following script can help you. You should not be running several copies of the script at the same time to avoid race condition. name=somefile if [[ -e $name.ext ]] ; then i=0 while [[ -e $name-$i.ext ]] ; do let i++ done

How to apply a Git patch to a file with a different name and path?

情到浓时终转凉″ 提交于 2019-12-17 17:26:51
问题 I have two repositories. In one, I make changes to file ./hello.test . I commit the changes and create a patch from that commit with git format-patch -1 HEAD . Now, I have a second repository that contains a file that has the same contents as hello.test but is placed in a different directory under a different name: ./blue/red/hi.test . How do I go about applying the aforementioned patch to the hi.test file? I tried git am --directory='blue/red' < patch_file but that of course complains that

upload images through php using unique file names

梦想与她 提交于 2019-12-17 16:37:15
问题 I am currently in the process of writing a mobile app with the help of phonegap. One of the few features that I would like this app to have is the ability to capture an image and upload it to a remote server... I currently have the image capturing and uploading/emailing portion working fine with a compiled apk... but in my php, I am currently naming the images "image[insert random number from 10 to 20]... The problem here is that the numbers can be repeated and the images can be overwritten..

Java Can't Open a File with Surrogate Unicode Values in the Filename?

孤街醉人 提交于 2019-12-17 12:48:05
问题 I'm dealing with code that does various IO operations with files, and I want to make it able to deal with international filenames. I'm working on a Mac with Java 1.5, and if a filename contains Unicode characters that require surrogates, the JVM can't seem to locate the file. For example, my test file is: "草鷗外.gif" which gets broken into the Java characters \u8349\uD85B\uDFF6\u9DD7\u5916.gif If I create a file from this filename, I can't open it because I get a FileNotFound exception. Even

How to get list of directories in Lua

旧街凉风 提交于 2019-12-17 10:26:39
问题 I need a list of directory in LUA Suppose I have a directory path as "C:\Program Files" I need a list of all the folders in that particular path and how to search any particular folder in that list. Example Need a list of all the folder in path "C:\Program Files" Below are folder name in the above path test123 test4567 folder 123 folder 456 folder 456 789 Need to get the above in a list and then have to search for a particular string like folder 456 in folder 456 789 only. Have Tried below

how do I clone files with colons in the filename

大憨熊 提交于 2019-12-17 09:54:06
问题 When I clone the repo using msysgit, all the files with spaces in the filename are not brought down, and then show as deleted in the status. The filenames looks something like this: styles-ie (1:12:11 6:02 PM).css so it might actually be the colon or brackets? How can I fetch those files to bring my local repo inline with the origin? 回答1: If you try doing: touch "styles-ie (1:12:11 6:02 PM).css" you will see that you cannot create it on Windows. Basically, the repo has the file ( the blob and

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

半腔热情 提交于 2019-12-17 08:04:13
问题 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 chars long. For example, this is a folder hierarchy that a single Node module can create: node_modules\nodemailer\node_modules\simplesmtp\node_modules\ xoauth2\node_modules\request\node_modules\form-data\node_modules\ combined-stream\node_modules

How to rename a file on sdcard with Android application?

寵の児 提交于 2019-12-17 06:43:39
问题 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..