Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [file-system]

Use this tag for reviews of code that performs file system operations, such as creating, deleting, renaming, moving, copying, reading, and writing files.

4
votes
2answers
54 views

Best way to retrieve music metadata from audio files?

I am using the music metadata-browser npm package to retrieve audio metadata from files. This library is being used in an Electron and React desktop app. To get the metadata of audio files, (and add ...
1
vote
0answers
36 views

Implementing std::filesystem::remove_all() for Android

I needed to use some c++ code on both standard Linux and the Android variant, and the code will use filesystem library but it isn't yet in the ndk. So I'm making a one to use on Android It will be ...
3
votes
0answers
29 views

Powershell script for zipping up old files

I have a script for zipping up old files. I know using Windows Compression isn't ideal, so I will make the script run using 7-Zip later on. For now though, I just want see how I can make my current ...
4
votes
1answer
62 views

Copy files from directory to SSH Server

The overall idea is: I have an Android phone and I would like to copy the files in a folder from the phone (which is running an SSH server, that's how I connect to it) to a harddrive connected to my ...
2
votes
2answers
71 views

Writing a ~100Kb HTML string over an MD file (number of iterations ~10K)

I have tried to write a large string (~100-120 Kb of HTML) on an md file, and am pretty sure it's not the fastest method, even though it only has to iterate ~8000-...
6
votes
2answers
1k views

Backup with Hanoi Strategy

I want your suggestions about this shell script. I use it to backup some configurations on my home media server. What improvements would you do? Keep in mind, I want to optimize space and speed and ...
7
votes
0answers
95 views

Python code to identify structure of a text file

We have a department in our org that generates a lot of data in flat files, all with different formats. We are now trying to sort this data out and load into a database. As step 1, I am trying to ...
0
votes
2answers
48 views

Search files content fast in powershell

I need to search a large repository of files for a specific resource, and return it only if it is used or not. It is working as expected, but it is very time consuming. To search for 50 resource ...
2
votes
1answer
33 views

Bash on Synology - Delete recycle bin entries over X days old

Synology NASs have a Task Scheduler that allows you to schedule deletion of files over X days old from recycle bins. This feature isn't working for me–running the task results in no files being ...
2
votes
1answer
43 views

Python script that alerts me when specific file gets created

I wrote a small script that opens a window using PyQt when a specific file gets created. This is to let me know when another program (that I have no control over) has finished calculating something. ...
0
votes
0answers
23 views

Using Python to list recent files in directory

I'm working with directory of raw data .csv files, stored daily in a directory with the same name except date stamp in the name, for example ...
3
votes
1answer
16 views

Tagging the directories and switching between them by tags - follow-up (Part 2/2: business logic)

This is the bash script responsible for changing the directories via textual tags. (See here the entire project.) dt_script ...
1
vote
1answer
30 views

Tagging the directories and switching between them by tags - follow-up (Part 1/2: File management)

This is a rework of a small program for faster(?) switching working directories, and it looks like a pile of crap, I must admit. Could you give me pointers how to make it maintainable? dt_tag_entry....
1
vote
0answers
26 views

Python script to add unittest decorators to source code files

This is a simple Python script to add @unittest.skipUnless() decorators in a specified format above every function starting with ...
2
votes
1answer
21 views

C Recursive Opendir Wrapper to Sort Directories First (ascending/descending)

A recent post on StackOverflow about a recursive directory listing which produced an unsorted mixed file/directory list, sparked the stray thought of "What would it take to write a wrapper for the ...
4
votes
1answer
302 views

Simple directory monitoring and processing file on appearance

Currently I am working on some kind of mechanism which will be able to monitor directory and when file with extension .pdf appears I need to mock some kind of ...
6
votes
1answer
85 views

Identify Duplicate Files

A friend of mine has the following issue. He has a nearly-full 1TB hard drive on which he keeps copies of all the pictures from his digital camera(s). However, he knows that he has copied the entire ...
2
votes
1answer
108 views

Making a catalog of pictures

Is there a way to make this code run faster? I have over 6000 pictures in .jpg optimized to a maximum of 40 kB. It starts quickly but after like 2000 pictures it runs way slower. The final .xlsm file ...
0
votes
0answers
21 views

Filtering files and directories

I want to filter directories and files by what they start with. ...
5
votes
1answer
39 views

Scheduled file sorting with Ruby

I have a script running as an hourly cron job. It finds all screenshots on the Desktop and moves them to directories sorted by year/month/day. On MacOS, screenshots are automatically saved to the ...
2
votes
3answers
79 views

Renaming all files/folders in first children folders but not sub-children

Let's say I have this folder tree: ...
3
votes
1answer
200 views

Writing to a file in Golang across concurrent go routines

I've been reading around how golang writes to a file, and this stack overflow question and this reddit question highlights the fact Go doesn't gurantee atomicity when writing to a file system. ...
2
votes
0answers
25 views

Script to report disk usage

I am trying to see how I can speed up the below script that reports disk usage. The timed find command towards the end is the problematic line that I am trying to ...
4
votes
2answers
86 views

Renumbering files in a folder consecutively

I wrote a program to rename files with consecutive numbers, basically removing the gaps in the numbering. This could be a very annoying task to do it manually in windows. I only did this for ...
5
votes
1answer
47 views

Find big files on the harddrive

For practicing Python I wrote a script which scans the harddrive for large files and lists them in a report. The script takes the root path and then all the subfolders are scanned aswell. Also the ...
1
vote
1answer
43 views

List directories, subdirectories and files, while ignoring some dirs

In my application, the user may or may not want to ignore some directories. I can do that, but it seems like I am repeating myself. Does anyone have an idea to refactor that? ...
9
votes
3answers
189 views

Multiple file access abstractions

When using dependency injection for nearly everything it's good to have some file access abstraction. I find the idea of ASP.NET Core FileProvider nice but not sufficient for my needs so inspired by ...
3
votes
2answers
52 views

Special FileLogger: write-all after 100 logs or before 1 second without new log

My question is about an easy FileLogger. I want the FileLoggers to store new logs in a collection, and write them in a file only if: - There are 100 logs if the collection - It's been more than 1 ...
2
votes
1answer
51 views

Unit tests for directory-entry counter

I have a function that simply counts the number of files in a directory. To test this function I am using temporary files which are great in the respect that they are deleted upon creating. However, ...
4
votes
1answer
42 views

Script to clean up old files that should only run one instance

I'm writing a bash script for deleting old files on a Linux server. Here are some relevant facts about this script: As currently written, it does work as expected. However, it's entirely possible ...
7
votes
2answers
119 views

Walking directory tree like python does

I like python's os.walk and I was missing it in C#. It's a very convenient API so I thought I create my own utility that does something similar. The original API ...
3
votes
2answers
67 views

Searching repositories for files with forbidden strings

I wrote a small tool for searching git repositories for forbidden strings that I don't want to commit publicly. It's still something basic but it does the job. The project contains three files. <...
3
votes
1answer
65 views

Moving or copying images from a flat directory to subdirectories

I have a huge Google Photos directory that is difficult to navigate - there are just too many files so I thougt I need to sort them somehow. I decided to make it simple and group them by date-taken. ...
2
votes
0answers
30 views

Trying to create a directory if it doesn't exist [closed]

I am trying to create a directory, but I have to check whether /usr is present initially, later /usr/local is present and so on, ...
0
votes
1answer
317 views

Delete temp files and empty recycle bin

I was wondering if someone could help critique this code I put together. It is supposed to delete all temp files and folders and then empty the recycle bin. I had to make some adjustments because ...
1
vote
0answers
42 views

Java Multipart text file analysis to zip

So I am working on a project that should take .txt file as an input and analyze words in it (assuming all words are English). Program must run asynchronously. Final output should be multiple .txt ...
1
vote
1answer
60 views

Find a folder in Java

I am making a website which should host a lot of PDFs. These PDFs are stored on the HDD. There are DossierIds in the database which correspondent with the folder name. In these folders there is 1 ...
2
votes
1answer
381 views

C++ - Object Oriented File System Design using Composite Design Pattern

I am trying to come up with a good File System Design using C++ / OOP. This is being done to gain an understanding of System Design and Design Patterns. I have some basic functionality, like reading ...
1
vote
1answer
82 views

Short Ruby program that opens a random video file from a directory

I am currently learning to code in ruby. I have created a small program that iterates through a directory of video files and opens one at random. The program is fully functioning (with the odd issue). ...
2
votes
0answers
45 views

Attempt to save (recover) files from a broken external drive

My external drive that I use for Backup had some broken files. I feared that I'd lose some (or all) the data in there. So I wanted to copy each and every file to my hard disk. I first tried using ...
1
vote
1answer
40 views

Powershell for syncing Minecraft save files

My code in full plus the task scheduler definition: https://gist.github.com/DaneWeber/0c5e7978bd3927734173e3afdc3d6338 This is my first non-trivial PowerShell script. This was a pretty major learning ...
-1
votes
1answer
284 views

Java code for delimited raw file read with multi line record

I have written a simple program to read file that contains record spread between multiple lines. There is requirement to read file from source that is dirty and contains line breaks which are ...
2
votes
1answer
29 views

Sorting files into subdirectories based on keyword scores

This script sorts files from current directory into known subdirectories. it is built for speed because the keyword database used can be up to 20kb. each line of the database has ...
6
votes
2answers
725 views

Pick a random file from a directory tree

I'm working on a python module to randomly choose a wallpaper for my desktop background among thousands of pictures in my photo library. I though I'd make a general function: ...
2
votes
1answer
48 views

OOP implementation of in-memory file system

I was working on this problem, where I am constructing a Object Oriented structure of file system where you can have Directories and Files. The Directories could have sub Directories and files. I ...
3
votes
2answers
157 views

Find duplicate files in Linux

This code finds duplicate files in Linux. I assume that MD5 hash will return unique hash number. What can I improve in this code? ...
4
votes
1answer
50 views

Simple server log backup script utilising AWS

I have server side log files written to various directories throughout the course of a week. I have the need to optionally compress, and archive these files to AWS. The script I have come up with ...
2
votes
1answer
107 views

Export data from matrix to txt file [closed]

I am new at programming and I'm really confused about how should I do this, because at first I thought I should ask user which path to export. However I have been told that I should check if it exists ...
1
vote
1answer
86 views

Loop through array of files and rsync to Dropbox

The goal is pretty straightforward. There’s a list of dotfiles from my home directory. It loops through them and rsyncs all file to a Dropbox folder for backup ...