This is a simple command-line tool written in Rust that organizes files in a directory based on their file types. It scans the specified directory and moves files into respective subdirectories based on their file extensions.
Before using this tool, ensure that you have the following installed:
- Rust programming language (https://www.rust-lang.org/tools/install)
-
Clone the repository or download the source code.
-
Open a terminal or command prompt.
-
Navigate to the project directory.
-
Build the project using the following command:
cargo build --release
-
Run the tool with the following command, specifying the directory to organize:
./target/release/file_organizer <directory_path>
Replace
<directory_path>
with the path to the directory you want to organize. -
The tool will scan the specified directory and organize the files based on their extensions into separate subdirectories.
The code is structured as follows:
- The
Directory
struct holds two vectors:file_names
for storing the names of files andextensions
for storing their corresponding extensions. - The
push
method of theDirectory
struct adds a tuple of(name, extension)
to the respective vectors. - The
FileNameParser
function takes astd::ffi::OsString
representing a file name and splits it into the name and extension parts. - The
main
function is the entry point of the program. It retrieves the input directory path from the command-line arguments, reads the directory contents, and organizes the files by callingFileNameParser
andpush
methods ofDirectory
.
Feel free to customize the file_extensions
array in the main
function to specify the file types you want to organize.
Please note that this tool will move the files within the specified directory, so use it with caution.
This project is licensed under the MIT License.