filenames

CarrierWave: Create the same, unique filename for all versioned files

杀马特。学长 韩版系。学妹 提交于 2019-12-02 20:32:15
Before I go into detail I'll get right to the point: has anyone figured out a way to get Carrierwave to save files with their names as a timestamp or any arbitrary string that is unique to each file? By default Carrierwave saves each file and its alternate versions in its own directory (named after the model ID number). I'm not a fan of this because instead of one directory with 1,000, for the sake of using a large round number, files (in my case pictures) in it we get one directory with 1,000 subdirectories each with one or two files. Yuck. Now, when you override your Uploader's store_dir

PHP Using str_replace along with preg_replace

本小妞迷上赌 提交于 2019-12-02 20:19:28
问题 I have a string of comma separated values that comes from a database, which actually are image paths. Like so: /images/us/US01021422717777-m.jpg,/images/us/US01021422717780-m.jpg,/images/us/US01021422717782-m.jpg,/images/us/US01021422718486-m.jpg I then do like below, to split them at the , and convert them into paths for the web page. preg_replace('~\s?([^\s,]+)\s?(?:,|$)~','<img class="gallery" src="$1">', $a) Works well, but in one place further in my page, I need to change the -m to -l

vb.net get filename list from wildcard

人走茶凉 提交于 2019-12-02 19:45:51
问题 I have string say "c:\debug\ *.txt" In Debug folder there are severeal .txt files , say test1.txt test2.txt test3.txt . How can I get from this string c:\debug\ *.txt an array of wildcard files? a(0)=c:\debug\test1.txt a(1)=c:\debug\test2.txt a(2)=c:\debug\test3.txt It is also possible that the string would be something like "C:\logs\12*\ *.log" a(0)=C:\logs\120114\01.log a(0)=C:\logs\120114\02.log a(0)=C:\logs\120114\03.log etc. Anyone have any ideas on this? 回答1: This should do it for you.

Get filename with date and trailing counter

三世轮回 提交于 2019-12-02 18:45:00
问题 I need to frame a file name as name_<date>_N , where N is a counter for the number of similar files. String fileName = "name"; String fileNameWithDate = fileName + "_"+ new SimpleDateFormat("MMM_dd_yyyy").format(cal.getTime()); If I try to download more times for a given date, the count should be incremented by 1; for example, name_Dec_10_2015_N . How do I get filename with date and incremented by 1? 回答1: As @MadProgrammer already wrote you need to do it in following steps get a list of all

.htm or .html extension - which one is correct and what is different?

帅比萌擦擦* 提交于 2019-12-02 18:41:33
When I save a file with an .htm or .html extension, which one is correct and what is different? Neither is wrong, it's a matter of preference. Traditionally, MS software uses htm by default, and *nix prefers html . As oded pointed out below, the .htm tradition was carried over from win 3.xx, where file extensions were limited to three characters. Mainly, the number of characters is different. ".htm" smells of Microsoft operating systems where the file system historically limited file name extensions (the part of the file name after the dot) to 3 characters. ".html" smells of Un*x operating

bash: interpret string variable as file name/path

自闭症网瘾萝莉.ら 提交于 2019-12-02 18:39:58
My bash script receives a filename (or relative path) as a string, but must then read from that file. I can only read from a filename if I declare it as a literal directly in the script (without quotes)...which is impossible for arguments since they are implicitly strings to begin with. Observe: a="~/test.txt" #Look for it if [[ -a $a ]] ; then echo "A Found it" else echo "A Error" fi #Try to use it while read line; do echo $line done < $a b='~/test.txt' #Look for it if [[ -a $b ]] ; then echo "B Found it" else echo "B Error" fi #Try to use it while read line; do echo $line done < $b c=~/test

Java searching file name from the one folder

北战南征 提交于 2019-12-02 18:10:15
问题 I am studying Java and I am not really sure the way to searching file. I would like to build the function which returning file names ( the files name should begin with star and end with .txt ) For example, in the folder we have Java source file with some file. For example, files: 1.txt 2.txt 4.txt start.txt star.txt onstart.txt starton.txt myjava.java Then I would like to get the start.txt , star.txt & starton.txt I was looking for the FilenameFilter but I wasn't able to find to good way to

How to make an NSString path (file name) safe

自古美人都是妖i 提交于 2019-12-02 17:53:07
I'm using very tricky fighting methods :) to make a string like Fi?le*/ Name safe for using as a file name like File_Name . I'm sure there is a cocoa way to convert it. And I'm sure the best place to ask is here :) Thank you! Unless you're explicitly running the shell or implicitly running the shell by using a function such as popen or system , there's no reason to escape anything but the pathname separator. You may also want to enforce that the filename does not begin with a full stop (which would cause Finder to hide the file) and probably should also enforce that it is not empty and is

How to add the timestamp as a part of the generated image file name in ffmpeg

柔情痞子 提交于 2019-12-02 17:35:36
问题 I am trying to extract png images from a video using ffmpeg and add the timestamp as a part of the generated image file name. Please see the below command I am using for the same ffmpeg -vcodec mpeg2video -f mpegts -i test_movie.ts -f image2 -vf "drawtext=fontfile=/Library/Fonts/Tahoma.ttf: timecode='$(date +%H\\:%M\\:%S).00': r=30: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" -vsync vfr -pattern_type glob ./compare_multiple_$(gdate +%H\_%M\_%S_%3N).png But this is

javascript url-safe filename-safe string

好久不见. 提交于 2019-12-02 17:15:38
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. Well, here's one that replaces anything that's not a letter or a number, and makes it all lower case, like your example. var s = "John Smith's Cool Page"; var filename = s.replace(/[^a-z0-9]/gi, '_').toLowerCase(); Explanation: The regular expression is /[^a-z0-9]/gi . Well, actually the gi at the end is just a set of options that are used when the expression is used. i means "ignore upper/lower