Questions tagged [filesystems]
A file system is a way of organizing data on a computer system. Typically a file system consists of files, folders (normally a special kind of file) and an API that can be used for interacting with files.
filesystems
9,642
questions
3798
votes
21
answers
3.7m
views
How to copy files
How do I copy a file in Python?
1087
votes
33
answers
1.3m
views
Exploring Docker container's file system
I've noticed with docker that I need to understand what's happening inside a container or what files exist in there. One example is downloading images from the docker index - you don't have a clue ...
1025
votes
28
answers
1.1m
views
How to use to find files recursively?
I would like to list all files recursively in a directory. I currently have a directory structure like this:
src/main.c
src/dir/file1.c
src/another-dir/file2.c
src/another-dir/nested/files/file3.c
I'...
644
votes
23
answers
396k
views
How many files can I put in a directory?
Does it matter how many files I keep in a single directory? If so, how many files in a directory is too many, and what are the impacts of having too many files? (This is on a Linux server.)
...
596
votes
16
answers
628k
views
Quickly create a large file on a Linux system
How can I quickly create a large file on a Linux (Red Hat Linux) system?
dd will do the job, but reading from /dev/zero and writing to the drive can take a long time when you need a file several ...
584
votes
8
answers
412k
views
Node.js check if path is file or directory
I can't seem to get any search results that explain how to do this.
All I want to do is be able to know if a given path is a file or a directory (folder).
575
votes
26
answers
618k
views
How do I get the path and name of the python file that is currently executing?
I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process.
For example, let's say I have three files. Using execfile:
...
569
votes
8
answers
812k
views
What's the best way to check if a file exists in C?
Is there a better way than simply trying to open the file?
int exists(const char *fname)
{
FILE *file;
if ((file = fopen(fname, "r")))
{
fclose(file);
return 1;
}
...
563
votes
22
answers
551k
views
How to recursively find and list the latest modified files in a directory with subdirectories and times
Operating system: Linux
Filesystem type: ext3
Preferred solution: Bash (script/one-liner), Ruby, or Python
I have several directories with several subdirectories and files in them. I need to make a ...
547
votes
35
answers
537k
views
Remove directory which is not empty
In my Node application I need to remove a directory which has some files, but fs.rmdir only works on empty directories. How can I do this?
515
votes
10
answers
408k
views
Folder management with r : Check existence of directory and create it if it doesn't exist
I often find myself writing R scripts that generate a lot of output. I find it cleaner to put this output into its own directory(s). What I've written below will check for the existence of a directory ...
504
votes
26
answers
654k
views
How to create a directory using Ansible
How do you create a directory www at /srv on a Debian-based system using an Ansible playbook?
475
votes
4
answers
521k
views
Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\"), Server.MapPath("/"). What is the difference?
Can anyone explain the difference between Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\") and Server.MapPath("/")?
472
votes
22
answers
640k
views
How to recursively delete an entire directory with PowerShell 2.0?
What is the simplest way to forcefully delete a directory and all its subdirectories in PowerShell? I am using PowerShell V2 in Windows 7.
I have learned from several sources that the most obvious ...
439
votes
26
answers
291k
views
Delete directories recursively in Java
Is there a way to delete entire directories recursively in Java?
In the normal case it is possible to delete an empty directory.
However when it comes to deleting entire directories with contents, it ...
438
votes
2
answers
385k
views
How to get a path to the desktop for current user in C#?
How do I get a path to the desktop for current user in C#?
The only thing I could find was the VB.NET-only class SpecialDirectories, which has this property:
My.Computer.FileSystem....
433
votes
14
answers
623k
views
Get a filtered list of files in a directory
I am trying to get a list of files in a directory using Python, but I do not want a list of ALL the files.
What I essentially want is the ability to do something like the following but using Python ...
417
votes
28
answers
520k
views
Can you call Directory.GetFiles() with multiple filters?
I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3's and jpg's. I have tried both of the following with no luck:
Directory.GetFiles("C:\\...
341
votes
19
answers
171k
views
How can I find all of the distinct file extensions in a folder hierarchy?
On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it.
What would be the best way to achieve this from a shell?
327
votes
29
answers
555k
views
"git submodule update" failed with 'fatal: detected dubious ownership in repository at...'
I mounted a new hard disk drive in my Linux workstation. It looks like it is working well. I want to download some repository in the new disk. So I execute git clone XXX, and it works well. But when I ...
326
votes
19
answers
426k
views
Open directory dialog
I want the user to select a directory where a file that I will then generate will be saved. I know that in WPF I should use the OpenFileDialog from Win32, but unfortunately the dialog requires file(s) ...
303
votes
6
answers
162k
views
Node.js - Find home directory in platform agnostic way
Process.platform returns "win32" for Windows. On Windows a user's home directory might be C:\Users[USERNAME] or C:\Documents and Settings[USERNAME] depending on which version of Windows is being used. ...
298
votes
8
answers
182k
views
Iterate through every file in one directory
How do I write a loop in ruby so that I can execute a block of code on each file?
I'm new to ruby, and I've concluded that the way to do this is a do each loop.
The ruby file will be executed from a ...
289
votes
22
answers
269k
views
How to recursively find the latest modified file in a directory?
It seems that ls doesn't sort the files correctly when doing a recursive call:
ls -altR . | head -n 3
How can I find the most recently modified file in a directory (including subdirectories)?
261
votes
12
answers
395k
views
Getting the folder name from a full filename path
string path = "C:\folder1\folder2\file.txt";
What objects or methods could I use that would give me the result folder2?
255
votes
12
answers
238k
views
fs: how do I locate a parent folder?
How do I write this to go back up the parent 2 levels to find a file?
fs.readFile(__dirname + 'foo.bar');
222
votes
29
answers
199k
views
How to determine MIME type of file in android?
Suppose I have a full path of file like:(/sdcard/tlogo.png). I want to know its mime type.
I created a function for it
public static String getMimeType(File file, Context context)
{
Uri ...
217
votes
8
answers
120k
views
What is the difference between a directory and a folder?
Most people use the terms "folder" and "directory" interchangeably. From a programmer point of view, is there a difference, and if so, what is it? Does it depend on the OS, or is ...
216
votes
8
answers
236k
views
Linux delete file with size 0 [duplicate]
How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script.
l filename.file | grep 5th-tab | not eq 0 | rm
Something like this?
205
votes
8
answers
144k
views
NTFS performance and large volumes of files and directories
How does Windows with NTFS perform with large volumes of files and directories?
Is there any guidance around limits of files or directories you can place in a single directory before you run into ...
204
votes
21
answers
264k
views
How to list only top level directories in Python?
I want to be able to list only the directories inside some folder.
This means I don't want filenames listed, nor do I want additional sub-folders.
Let's see if an example helps. In the current ...
189
votes
3
answers
199k
views
Notepad++ cached files location
On the most recent versions of Notepad++, when the application is closed, unsaved files are maintained when the application is restarted.
I presume that those files are cached on a temporary files. ...
181
votes
27
answers
196k
views
How do I check if a given string is a legal/valid file name under Windows?
I want to include a batch file rename functionality in my application. A user can type a destination filename pattern and (after replacing some wildcards in the pattern) I need to check if it's going ...
179
votes
4
answers
169k
views
Checking if a folder exists (and creating folders) in Qt, C++
In Qt, how do I check if a given folder exists in the current directory?
If it doesn't exist, how do I then create an empty folder?
179
votes
10
answers
366k
views
How to copy a file from one directory to another using PHP?
Say I've got a file test.php in foo directory as well as bar. How can I replace bar/test.php with foo/test.php using PHP? I'm on Windows XP, a cross platform solution would be great but windows ...
178
votes
10
answers
134k
views
How do you determine the ideal buffer size when using FileInputStream?
I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize ...
173
votes
18
answers
164k
views
What is the best place for storing uploaded images, SQL database or disk file system? [closed]
I'm writing an application that allows users to upload images onto the server. I expect about 20 images per day all jpeg and probably not edited/resized. (This is another question, how to resize the ...
170
votes
19
answers
235k
views
How do you iterate through every file/directory recursively in standard C++?
How do you iterate through every file/directory recursively in standard C++?
168
votes
12
answers
141k
views
What character to use to put an item at the end of an alphabetic list? [closed]
I often prepend '_____' to the item I want in first position.
Is there some sort of magical character I could use to put an item at the end of the list?
Something more elegant than "z_item".
...
165
votes
13
answers
313k
views
How can I search sub-folders using glob.glob module? [duplicate]
I want to open a series of subfolders in a folder and find some text files and print some lines of the text files. I am using this:
configfiles = glob.glob('C:/Users/sam/Desktop/file1/*.txt')
But ...
159
votes
10
answers
380k
views
GIT_DISCOVERY_ACROSS_FILESYSTEM not set
I have searched and read few post but my problem is not the same as described. So here's the issue: using git clone into folder under external partition of the disk works fine but all git commands ...
154
votes
11
answers
51k
views
File system that uses tags rather than folders?
My files are a mess, I try to structure them into folders with names that describe what they are in a recursive class break-down sense but later on I have trouble finding the file again when I go ...
150
votes
12
answers
237k
views
How do I programmatically change file permissions?
In Java, I'm dynamically creating a set of files and I'd like to change the file permissions on these files on a linux/unix file system. I'd like to be able to execute the Java equivalent of chmod. ...
142
votes
6
answers
164k
views
Check whether a path is valid in Python without creating a file at the path's target
I have a path (including directory and file name).
I need to test if the file-name is a valid, e.g. if the file-system will allow me to create a file with such a name.
The file-name has some unicode ...
138
votes
8
answers
212k
views
Determine file creation date in Java
There is another similar question to mine on StackOverflow (How to get creation date of a file in Java), but the answer isn't really there as the OP had a different need that could be solved via other ...
128
votes
19
answers
388k
views
How do I include a file over 2 directories back?
How do you include a file that is more than 2 directories back. I know you can use ../index.php to include a file that is 2 directories back, but how do you do it for 3 directories back?
Does this ...
127
votes
8
answers
150k
views
Path.Combine absolute with relative path strings
I'm trying to join a Windows path with a relative path using Path.Combine.
However, Path.Combine(@"C:\blah",@"..\bling") returns C:\blah\..\bling instead of C:\bling\.
Does anyone know how to ...
124
votes
5
answers
208k
views
Loop code for each file in a directory [duplicate]
I have a directory of pictures that I want to loop through and do some file calculations on. It might just be lack of sleep, but how would I use PHP to look in a given directory, and loop through each ...
122
votes
19
answers
140k
views
Get size of folder or file
How can I retrieve size of folder or file in Java?
119
votes
10
answers
232k
views
How to check type of files without extensions? [duplicate]
I have a folder full of files and they don't have an extension. How can I check file types? I want to check the file type and change the filename accordingly. Let's assume a function filetype(x) ...