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
Filter by
Sorted by
Tagged with
3798 votes
21 answers
3.7m views

How to copy files

How do I copy a file in Python?
Matt's user avatar
  • 86.2k
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 ...
user2668128's user avatar
  • 40.6k
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'...
Ben Gartner's user avatar
  • 14.7k
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.) ...
Kip's user avatar
  • 108k
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 ...
DrStalker's user avatar
  • 9,281
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).
ThomasReggi's user avatar
  • 57.2k
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: ...
Ray's user avatar
  • 190k
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; } ...
Dave Marshall's user avatar
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 ...
fredrik's user avatar
  • 5,763
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?
sachin's user avatar
  • 14k
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 ...
Chase's user avatar
  • 68.3k
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?
Gaurav Agarwal's user avatar
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("/")?
Manu's user avatar
  • 28.9k
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 ...
Matt Spradley's user avatar
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 ...
paweloque's user avatar
  • 18.7k
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....
Cristian Diaconescu's user avatar
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 ...
mhost's user avatar
  • 7,060
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:\\...
Jason Z's user avatar
  • 13.3k
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?
GloryFish's user avatar
  • 13.2k
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 ...
Huihua Jiang's user avatar
  • 3,371
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) ...
Alexandra's user avatar
  • 4,773
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. ...
Matthew's user avatar
  • 11.4k
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 ...
Andrew's user avatar
  • 2,981
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)?
JMW's user avatar
  • 7,497
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?
Ash Burlaczenko's user avatar
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');
fancy's user avatar
  • 50.1k
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 ...
Sushant Bhatnagar's user avatar
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 ...
mafu's user avatar
  • 32.2k
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?
Franz Kafka's user avatar
  • 10.8k
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 ...
James Newton-King's user avatar
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 ...
fuentesjr's user avatar
  • 51.6k
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. ...
RedEagle's user avatar
  • 4,468
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 ...
tomash's user avatar
  • 12.9k
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?
Switch's user avatar
  • 5,286
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 ...
Ali's user avatar
  • 265k
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 ...
ARKBAN's user avatar
  • 3,439
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 ...
Tobias's user avatar
  • 5,054
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++?
robottobor's user avatar
  • 11.7k
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". ...
Kraz's user avatar
  • 7,020
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 ...
UserYmY's user avatar
  • 8,354
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 ...
user755's user avatar
  • 2,601
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 ...
clinux's user avatar
  • 3,014
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. ...
Roy Rico's user avatar
  • 3,753
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 ...
Fake Name's user avatar
  • 5,644
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 ...
Todd's user avatar
  • 1,905
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 ...
user avatar
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 ...
CVertex's user avatar
  • 18.1k
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 ...
Chiggins's user avatar
  • 8,297
122 votes
19 answers
140k views

Get size of folder or file

How can I retrieve size of folder or file in Java?
oneat's user avatar
  • 10.9k
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) ...
emnoor's user avatar
  • 2,638

1
2 3 4 5
193