filenames

How to reliably get the filename without the suffix in javascript?

纵饮孤独 提交于 2019-12-24 12:05:32
问题 Whats the reliable way on getting the filename of a file by removing suffix in javascript? I have a file let's say : http://example.com/uploads/images/a51dd42_thumb.jpg and http://example.com/uploads/images/a51dd42_s.jpg Now i want to get the string http://example.com/uploads/images/a51dd42.jpg replace() function is not what i want since images filename could have many different types of suffixes Maybe regex is the best for this? If yes, whats the reliable code for it? Thanks in advance 回答1:

Retrieving info from a file

为君一笑 提交于 2019-12-24 11:36:14
问题 This code retrieves information from another site: <?php $location = $ident; get_taf($location); function get_taf($location) { $fileName = "ftp://tgftp.nws.noaa.gov/data/forecasts/taf/stations/$location.TXT"; $taf = ''; $fileData = @file($fileName); if ($fileData != false) { list($i, $date) = each($fileData); $utc = strtotime(trim($date)); $time = date("D, jS M Y Hi",$utc); while (list($i, $line) = each($fileData)) { $taf .= ' ' . trim($line); } $taf = trim(str_replace(' ', ' ', $taf)); } if(

Merging multiple csv files with name sequence

﹥>﹥吖頭↗ 提交于 2019-12-24 11:09:37
问题 I am trying to merge 700+ csv files in R. I was able to merge them successfully using the code: library(dplyr) library(readr) df <- list.files(full.names = TRUE) %>% lapply(read_csv) %>% bind_rows Now my problem is the file names are saved as flux.0, flux.1, flux.2......flux.733. The R binds the files in order of flux.0, flux.1, flux.10, flux.100, flux.101...and so on. Since the sequence of the file is important for me, can you suggest to incorporate this in the above code? Many Thanks for

Win 7: CMD batch file for creating directories based on filenames

萝らか妹 提交于 2019-12-24 10:58:41
问题 I'm working on a CMD line batch file in a Win7 environment that will create directories based upon the filenames listed in a directory. I am using this code, but the output created is partial and incomplete with only setlocal enabledelayedexpansion for /r %%i in (*.wav) do ( set filename1=%%i set folder1=!filename1:~4,10! mkdir !folder1! ) pause I have this script saved as a CMD file in text format in the source directory, on a local harddrive, though it is in a subdirectory. The directory

i want to create a VBA code in Word that will create multiple word files with different file names

丶灬走出姿态 提交于 2019-12-24 10:39:49
问题 I want to create multiple saves of the same word file using visual basic. each file will need to be named with the day of the month and month name (not numbers) i want this to run from the 1 to 31 on each month. i have a rough code, Sub Mine() Dim DateStr, FileStr As String DateStr = Format$(Date, "DD") FileStr = DateStr & ".docx" ActiveDocument.Save ChangeFileOpenDirectory "Z:\FIR MASTER FOLDER\FCR briefing sheet\2018\Test" ActiveDocument.SaveAs2 FileName:=FileStr, FileFormat:

Using applescript, can I change filename without modifying (or getting) the file extension?

谁都会走 提交于 2019-12-24 10:37:47
问题 I am trying to change the name of a file. Seems simple enough, if one is able to change the "displayed name" property. But I keep getting this error: Can't set displayed name of alias "Path:to:file:" to "New_name" Here's the folder action script I'm using (i.e. saved applescript, then used folder action setup service to assign it to my folder): on adding folder items to this_folder after receiving these_items try repeat with this_item in these_items tell application "Finder" to set displayed

Distinguish a filename from an URL

倾然丶 夕夏残阳落幕 提交于 2019-12-24 08:40:34
问题 In WeasyPrint’s public API I accept either filenames or URLs (among other types) for the HTML input: document = HTML(filename='/foo/bar/baz.html') document = HTML(url='http://example.net/bar/baz.html') There is also the option not to name the argument and let WeasyPrint guess its type: document = HTML(sys.argv[1]) Some cases are easy: if it starts with a / on Unix it’s a filename, if it starts with http:// it’s probably an URL. But we need an general algorithm that gives an answer for any

Sorting file names by numeric value

大兔子大兔子 提交于 2019-12-24 06:16:07
问题 Preamble: I hate to ask questions like this, but I'm stuck with it and just learning Perl... seems like an easy task but I don't know where to look. I have a folder with lots of xml-files that are all named ".xml". I need to process those files in their numeric order, so "9123.xml" should come before "2384747.xml". I have successfully sorted the list alphabetically with this: opendir(XMLDIR,$xmldirname); my @files = sort {$a cmp $b} readdir(XMLDIR); but this isn't what I need. I also tried my

Python- creating a text file with a variable as a name

对着背影说爱祢 提交于 2019-12-24 03:58:05
问题 So im doing a project where my program creates a textfile named "Ten Green Bottles" and writes the 10 green bottles song in it, I have successfully got it working but i want to make it better. I started by making the amount of bottles optional to the user and it worked fine. Now i just want the name to be relevent with the amount of bottles input by the user. ie, if I put in 20 bottles i want the name of the text file to be "Twenty Green Bottles" rather than "Ten Green Bottles" Code: num1=int

Python zipfile module - zipfile.write() file with turkish chars in filename

≡放荡痞女 提交于 2019-12-24 00:39:19
问题 On my system there are many Word documents and I want to zip them using the Python module zipfile . I have found this solution to my problem, but on my system there are files which contain German umlauts and Turkish characters in their filename. I have adapted the method from the solution like this, so it can process German umlauts in the filenames: def zipdir(path, ziph): for root, dirs, files in os.walk(path): for file in files: current_file = os.path.join(root, file) print "Adding to