answersLogoWhite

0


Best Answer

== == In a programming context, one usually determines whether a file is a directory using functions that access file metadata. These are dependent on the system you are programming and what language you are programming in. You should consult a reliable reference for the programming language, such as the manpages for C and C++ (in Unix-like systems) or Java's Javadocs (available on the web).

To list all files in a directory, a programmer will usually iterate across all members of the directory and print some form of information found in the file metadata, such as the filename. ---- A parent directory is the directory containing the current directory. A child directory is a directory inside of the current directory. A subdirectory is a directory inside of the current directory or any its child directories.

----

In Windows, the most common way to determine if a file is a directory is using the GUI. To do this, right-click the file icon and click "Properites". If it is a directory, then the type of the file should be listed as "File Folder". Alternately, you can use the Command Prompt, which by default (Windows XP) can be accessed via the Start menu, in the Applications folder. Alternately, type "cmd" into the Run prompt (or the search field in Vista). You will be presented with a command line interface. Use the command "CD" followed by a file path to change to the desired directory, then type "DIR /A:D". This will list all files in the current directory with the attribute "directory". Alternately, you can include a path to the DIR command, such as "DIR /A:D C:\WINDOWS", to display the contents of the directory in the path.

To list all files in subfolders, use the command "DIR /S". The /S flag will cause subdirectories to be printed as well. Usage of "ls" is explained in full in the manpages, try invoking "man ls" on your system for more information. In Windows systems using the NTFS filesystem, drives are mounted as separate entities and the root folder of a drive is the drive letter, followed by a colon and a backslash (i.e. "C:").

----

In Unix-like systems, the most common utility is the command "ls". Remember that such systems are case-sensitive, so capitalization matters.

To use it, open up a shell emulator, such as bash or csh, and type "cd" followed by a path to change to that directory (or include a desired path to the subsequent commands). Type "ls" to see a listing of all files in the current directory, or "ls /bin" to see a listing of all files in the directory "/bin". By adding in the arguments "l" and "a", as in the command "ls -la", you can additionally see the file permissions (starting with a 'd' if they are a directory), and the "." and ".." directories, respectively.

To display the files in all subdirectories, add the argument 'R' to your list of arguments (or just do "ls -R" if you don't require more extensive information).

Usage of "ls" is explained in full in the manpages, try invoking "man ls" on your system for more information.

If you are using the bash shell, you can use pipes ('|') to chain together several programs to do such things as search or sort your results from the previous program. For example, "ls -l | grep foo" would first list the contents of the current directory (ls), then search through them and print out only those containing the string "foo" (grep).

In most of these systems, storage devices are mounted to mountpoints, which are treated as directories within the system's directory tree. The root directory is "/". Every directory has a link to itself (".") and a link to the parent directory (".."). The root directory is special in that ".." also links back to the root directory.

User Avatar

Wiki User

โˆ™ 2009-05-13 03:02:49
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar

Add your answer:

Earn +20 pts
Q: How can you tell whether a given file is a directory and how can you list all files in a directory including subfolders?
Write your answer...
Submit
Related questions

What type of program is TreeSize?

The TreeSize program or application can rapidly scan directory sizes and search space hogs. It shows the size of folders, subfolders, and files, and analyzes them.


To encrypt all files in the comp folder as well as its subfolders?

cipher /S


What is a java directory?

collection of files and directory


What does the command CD do?

CD stands for "change directory". For instance, if you are in the directory of c:\files\ and you want to navigate to a folder within the "files" directory called "documents", you can type "cd documents" to change the directory you are in. Once you've done that you will be at c:\files\documents\. Inversely you can use "cd.." to go back to the parent directory "files".


What is the command to be used to see all the files in a directory?

The command in a terminal is: ls (short for List). This will list the files in the current directory. Whilst in the Home directory, to list the files in a different directory, for instance Videos, use: ls Videos.


How do you move files to a directory in Linux?

mv file /path/to/directory


What is the directory used for?

A directory is a holding place for multiple files and sub-directories. Are you asking about a specific directory?


What does a directory store on computers?

A computer directory contains files and folders for that section of the computer or installed software, for example the Windows directory on a PC contains files that are important for running windows.


What is a directory in DOS?

A directory in DOS is like a folder in Windows: a collection of files.


What is a directory in the Linux filesystem?

A directory is a "folder" in Windows terminology. A directory is a file that contains references to other files.


What allows businesses to define manage access and secure network resources including files printers people and application?

Directory Services


What do you use to encrypt all files in the Comp folder as well as its subfolders?

You can use encryption software like TrueCrypt.


Is a directory a type of file?

A directory is also known as a folder. It is not a file, rather it is where files are stored. Generally many directories make up a program. And many files are contained in each directory.


How do you delete a folder from command prompt?

In Windows, it will be rmdir or rd. In Unix-based or Unix-like systems, the command is rmdir (however, it will not delete any folders that still have subfolders or files inside - for this, you use rm -r <name of folder to delete> to delete the folder and any files or subfolders).


What Unix directory is used to store executable files?

Several directories can be used to store executables, including /bin, /sbin, and /usr/bin.


What does the command ls-al?

This command lists the contents of the current working directory in a long listing format, including normally hidden files.


What folder folder permission specifically grants the right to see the names of files and subfolders within a folder?

read and execute


What folder in vista is intended to be used for files and folders that all users share?

The "C:\Users\Public" folder and its subfolders


What special permission should be set on public directories to prevent users from deleting files that others users have contributed?

In UNIX, this is the "sticky bit"... if set on a directory, only the owner of the directory, the owner of the individual file, and the superuser are allowed to delete files created in that directory. If not set, anyone with write permission on the directory can delete or rename files in it.


What types of information do directory lists generally contain?

A directory list usually contains lists of information. An example of a physical directory list would be the Yellow Pages. For computers, a directory list would either be a list of files or a list of links to other files.


What is the command is used to remove directory in Linux?

Assuming the directory is in your Home directory use: rmdir directory-name This will fail if there are files within the directory. In this case, use rm -r directory-name.


What is the a directory?

A directory in a computer is a section of the hard drive that contains files. A directory is important for file storage and easy accessibility for later use.


What is the System32 directory on a Windows system?

The System32 directory on a Windows system is a place for storing files. The System32 directory is located in the C drive.


Can a folder contain a directory and a file?

A folder is a directory. Folders can be inside other folders, and so can files...


How many files or entries can be included in the root directory?

The number of files or entries that can be included in a root directory will vary. However, they typically do not hold more than 512 entries.

Study guides

๐Ÿ““
Create a Study Guide