dir

Outputting result of “dir” to console in Java

与世无争的帅哥 提交于 2019-12-04 07:03:45
问题 I want to output the result of the "dir" command to the java console. I have already looked on Google and here, but none of the examples work for me, thus making me rite this post. My code is as follows: try { System.out.println("Thread started.."); String line = ""; String cmd = "dir"; Process child = Runtime.getRuntime().exec(cmd); //Read output BufferedReader dis = new BufferedReader( new InputStreamReader(child.getInputStream() )); while ((line = dis.readLine()) != null) { System.out

Ruby list directory with Dir['*'] including dotfiles but not . and

…衆ロ難τιáo~ 提交于 2019-12-03 23:35:57
How do I get Dir['*'] to include dotfiles, e.g., .gitignore , but not . and .. ? I.e., is there a better way to do: `ls -A`.split "\n" perhaps with Dir ? The following solutions are close but both include . & .. : Dir.glob('*', File::FNM_DOTMATCH) Dir['{.*,*}'] So, the following works: Dir.glob('*', File::FNM_DOTMATCH) - ['.', '..'] But, is there still a better way to do this? I'm wondering this to fix line 9 of a Meteor Homebrew Formula . You can't with Dir[] , but you can with Dir.glob , which Dir[] calls: Dir.glob("*", File::FNM_DOTMATCH) You can get rid of the . & .. easily: Dir.glob("*",

Batch file that returns folder size

喜夏-厌秋 提交于 2019-12-03 13:29:29
I'm having space issues on my Vista machine and need to figure out what's taking up so much space. I would like to write a simple batch file that returns all folders under C: and the size of each folder. The dir command doesn't appear to return folder size. Unfortunately we don't have admin rights and can't install a third party application and we have other users in our group that also need this information. Mark Mayo I'd have a look at this thread for some clues as to how to achieve the directory size: Batch File To Display Directory Size Otherwise: dirsize: @echo off setLocal

Python “dir” equivalent in Clojure

走远了吗. 提交于 2019-12-03 11:37:50
问题 Does anybody know if there is a Clojure equivalent for Pythons "dir". Basically I need to know the functions I can call on something or more specifically for java objects I want to know the methods and properties available (I am not sure if in java they are called methods and properties, this is C# lingo). 回答1: clojure.contrib.repl-utils/show for use at the REPL: user=> (use '[clojure.contrib.repl-utils :only (show)]) nil user=> (show String) === public final java.lang.String === [ 0] static

equivalent of (dir/b > files.txt) in PowerShell

倾然丶 夕夏残阳落幕 提交于 2019-12-03 10:46:59
dir/b > files.txt I guess it has to be done in PowerShell to preserve unicode signs. Get-ChildItem | Select-Object -ExpandProperty Name > files.txt or shorter: ls | % Name > files.txt However, you can easily do the same in cmd : cmd /u /c "dir /b > files.txt" The /u switch tells cmd to write things redirected into files as Unicode. Get-ChildItem actually already has a flag for the equivalent of dir /b : Get-ChildItem -name (or dir -name ) Richard In PSH dir (which aliases Get-ChildItem ) gives you objects (as noted in another answer ), so you need to select what properties you want. Either

PHP __DIR__ evaluated runtime (late binding)?

左心房为你撑大大i 提交于 2019-12-03 07:49:50
Is it somehow possible to get the location of PHP file, evaluated at runtime? I am seeking something similar to the magic constant __DIR__ , but evaluated at runtime, as a late binding. Similar difference with self and static : __DIR__ ~ self ??? ~ static My goal is defining a method in an abstract class, using __DIR__ which would be evaluated respectively for each heir class. Example: abstract class Parent { protected function getDir() { // return __DIR__; // does not work return <<I need this>>; // } } class Heir extends Parent { public function doSomething() { $heirDirectory = $this->getDir

Windows command line search for exact extension with dir

我与影子孤独终老i 提交于 2019-12-03 01:34:11
When I do a search: dir /b /s *.txt I get all files/folders with the extension .txt . But I also get them when they have an extension like .txtx . How can I search for the exact extension? you can try this dir /s /b *.txt | findstr /v .txt. or dir /s /b *.txt | findstr /e .txt or dir /b *.txt | findstr .txt$ I can't figure out why it behaves like this, but this works: dir /b /s .txt | findstr /e .txt . Ugly but works. 来源: https://stackoverflow.com/questions/2423935/windows-command-line-search-for-exact-extension-with-dir

Command to list all files in a folder as well as sub-folders in windows

浪子不回头ぞ 提交于 2019-12-03 00:02:48
问题 I tried searching for a command that could list all the file in a directory as well as subfolders using a command prompt command. I have read the help for "dir" command but coudn't find what I was looking for. Please help me what command could get this. 回答1: The below post gives the solution for your scenario. dir /s /b /o:gn /S Displays files in specified directory and all subdirectories. /B Uses bare format (no heading information or summary). /O List by files in sorted order. 回答2: If you

Outputting result of “dir” to console in Java

∥☆過路亽.° 提交于 2019-12-02 11:25:27
I want to output the result of the "dir" command to the java console. I have already looked on Google and here, but none of the examples work for me, thus making me rite this post. My code is as follows: try { System.out.println("Thread started.."); String line = ""; String cmd = "dir"; Process child = Runtime.getRuntime().exec(cmd); //Read output BufferedReader dis = new BufferedReader( new InputStreamReader(child.getInputStream() )); while ((line = dis.readLine()) != null) { System.out.println("Line: " + line); } dis.close(); }catch (IOException e){ } What am I doing wrong? Any help would be

how to use loop to get values in dir()?

∥☆過路亽.° 提交于 2019-12-02 08:46:13
问题 Why i can't get the values in the items in dir() with loop: for item in dir(): print(item) It just print __builtins__ __doc__ __loader__ __name__ __package__ __spec__ So, how can i use loop to print the value in item, i.e "__main__" in __name__ Thanks! 回答1: Calling dir without the argument is logically equivalent to list(locals()) , as in getting the list of names of variables in the current namespace ( keys of locals() dictionary). You'd use the items method of locals() instead: In [5]: for