directory

Powershell colored directory listing is incorrect with format-wide

大城市里の小女人 提交于 2019-12-19 04:03:41
问题 I got this colored dir script from http://tasteofpowershell.blogspot.com/2009/02/get-childitem-dir-results-color-coded.html: function ls { $regex_opts = ([System.Text.RegularExpressions.RegexOptions]::IgnoreCase -bor [System.Text.RegularExpressions.RegexOptions]::Compiled) $fore = $Host.UI.RawUI.ForegroundColor $compressed = New-Object System.Text.RegularExpressions.Regex('\.(zip|tar|gz|rar)$', $regex_opts) $executable = New-Object System.Text.RegularExpressions.Regex('\.(exe|bat|cmd|ps1|psm1

How to create a folder in C (need to run on both Linux and Windows)

对着背影说爱祢 提交于 2019-12-19 03:15:32
问题 I don't have much experience and I'm on a C project where I need to create & delete folders and the program must run on both Linux and Windows. I saw few solutions but all were either for Windows or Linux but none for both and most uses system(...). Also, if there is an easy way to delete a folder with it's contents, I'm interrested (for the moment I delete each files one by one and then the folder with remove(...)) Thanks in advance. 回答1: Here is a common 'create directory' method: void make

urllib downloading contents of an online directory

社会主义新天地 提交于 2019-12-19 02:28:20
问题 I'm trying to make a program that will open a directory, then use regular expressions to get the names of powerpoints and then create files locally and copy their content. When I run this it appears to work, however when I actually try to open the files they keep saying the version is wrong. from urllib.request import urlopen import re urlpath = urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/') string = urlpath.read().decode('utf-8') pattern = re.compile('ch

urllib downloading contents of an online directory

不羁的心 提交于 2019-12-19 02:28:05
问题 I'm trying to make a program that will open a directory, then use regular expressions to get the names of powerpoints and then create files locally and copy their content. When I run this it appears to work, however when I actually try to open the files they keep saying the version is wrong. from urllib.request import urlopen import re urlpath = urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/') string = urlpath.read().decode('utf-8') pattern = re.compile('ch

Fast test if directory is empty

自古美人都是妖i 提交于 2019-12-18 21:48:28
问题 What is the fastest way to test if a directory is empty? Of course I can check the length of list.files(path, all.files = TRUE, include.dirs = TRUE, no.. = TRUE) but this requires enumerating the entire contents of the directory which I'd rather avoid. EDIT : I'm looking for portable solutions. EDIT^2 : Some timings for a huge directory (run this in a directory that's initially empty, it will create 100000 empty files): system.time(file.create(as.character(0:99999))) # user system elapsed # 0

Subfolder directory browsing in Apache2

邮差的信 提交于 2019-12-18 21:27:13
问题 Got a folder at http://myserver/folder/, I have disabled directory browsing for that folder. But I want to enable directory browsing for the subfolders of http://myserver/folder/ How can I do this?? Thanks. 回答1: here's a working simple solution: <Directory /path/to/docroot/folder> Options -Indexes </Directory> <DirectoryMatch /path/to/docroot/folder/(.)*/> Options +Indexes </DirectoryMatch> 回答2: If you do not control apache, you can do this in a per-directory basis in your own files adding

Python cant get full path name of file

梦想与她 提交于 2019-12-18 19:40:14
问题 Trying to drill through a directory on my drive that has subfoldrs within it. When I find files that have the file extensions I'm looking for I want the full file path. Right now this is what I have: import os import Tkinter import tkFileDialog from Tkinter import Tk from tkFileDialog import askopenfilename root = Tkinter.Tk().withdraw() dirname = tkFileDialog.askdirectory(initialdir='.') list = [] for root, dirs, files in os.walk(dirname): for name in files: if name.find(".txt") != -1: name

Difference between os.path.exists and os.path.isfile in python

前提是你 提交于 2019-12-18 18:53:19
问题 I'm curious when these two functions will return different values. Also if you could clarify the difference between a path/directory/file that would be appreciated. 回答1: As you have already found out, the difference between exists and isfile is the fact that the former returns True in case the given path is a directory or a file, while the latter only returns True if the path points to a file. Directories and files are quite similar from the technical point of view. A file can contain any

Php Video Upload Script

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 18:27:05
问题 I am trying to allow users to upload videos via this form <form method='POST' name='uploadform' enctype='multipart/form-data' action=''> Video: <input type='file' name='filename' /><br/> <input type='submit' name='cmdSubmit' value='Upload' />"; Then with this php script I am trying to move the videos into another folder for storage. if($_POST['cmdSubmit']){ $filename = basename($_FILES['filename']['name']); move_uploaded_file($_FILES['filename']['tmp_name'], "videos/" . $filename); } The

android dcim folder path

浪子不回头ぞ 提交于 2019-12-18 17:55:09
问题 is there a way to get the DCIM path (it may be on sdcard or on device)on Api level 7? Environment.DIRECTORY_DCIM is available only from api level 8 回答1: I think the DCIM directory is never on the internal storage (My HTC Legend won't even take photo's without an sd-card present). The Environment.DIRECTORY_DCIM variable is just the String "DCIM" ref. The reason for storing images in /DCIM is compatibility with cardreaders (printers for example) who expect pictures to be available in /DCIM, so