Git Product home page Git Product logo

norman-codes / flag2folder Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29 KB

Flag2Folder is a Python tool for automated file organization, allowing users to sort files into designated folders based on specified filename flags. It offers a user-friendly console interface for easy setup of flag/folder pairs and dynamic directory selection, streamlining file management tasks.

Python 100.00%

flag2folder's Introduction

Flag2Folder: File Organization Tool

________/\\\\\____/\\\\\\\\\____________/\\\\\_        
 ______/\\\///___/\\\///////\\\________/\\\///__       
  _____/\\\______\///______\//\\\______/\\\______      
   __/\\\\\\\\\_____________/\\\/____/\\\\\\\\\___     
    _\////\\\//___________/\\\//_____\////\\\//____    
     ____\/\\\__________/\\\//___________\/\\\______   
      ____\/\\\________/\\\/______________\/\\\______  
       ____\/\\\_______/\\\\\\\\\\\\\\\____\/\\\______ 
        ____\///_______\///////////////_____\///_______

Overview

Welcome to Flag2Folder! This tool allows you to organize files into specified folders based on flags in their filenames. It's a simple yet powerful way to manage your files, whether they are images, documents, or any other type.

Use Case

Ideal for organizing datasets, managing document libraries, or simply keeping your download folder uncluttered. Whether you're a data scientist, a software developer, or just someone who loves organization, Flag2Folder is here to help streamline your file management.

Key Features

  • Custom Flag/Folder Mapping: Users can define unique flags and corresponding folder names. Files containing these flags in their names are automatically moved to the specified folders.
  • Directory Flexibility: Set source and destination directories with ease. The tool defaults to the current directory but allows for quick changes as needed.
  • Interactive Console Interface: Straightforward and user-friendly, the console interface guides users through setting flags, adding/removing folder pairs, and executing the sorting process.
  • Preview & Confirmation: Before executing, the tool provides a preview of the expected file organization, requiring user confirmation to proceed. This ensures accuracy and user control.

Getting Started

  • Clone the repository and run the script in a Python environment.
    • Or test it out online on Replit!
  • Follow the interactive prompts to set your flag/folder pairs and directories.
  • Execute and watch your files get organized effortlessly!

How to Use

  1. Choose Your Files: Start by choosing the files you want to work on and placing the script in the same directory as them.

  2. Run the Script: This is a console-based program, so running it in some type of terminal is necessary. This can be done in a native terminal application, or within an IDE such as VS Code.

  3. Set Directories (Optional):

    • The script uses the current working directory by default.
    • To change source and destination directories, use the [S]et directories option.
  4. Manage Flag/Folder Pairs:

    • Add: Use the [A]dd action to create flag/folder pairs. Flags are keywords the script looks for in filenames, and each flag is linked to a folder.
      • The relationship between flags and folders is "many-to-one". In other words, you can have one or more flags but they must lead to one folder.
    • Remove: Select [R]emove to delete a specific flag/folder pair.
    • Clear All: Choose [C]lear all to remove all flag/folder pairs.
  5. Execute File Organization:

    • With your flag/folder pairs set, use the [E]xecute action to start organizing your files. Files with specified flags in their names will be moved to the designated folders.
  6. Review and Exit:

    • After execution, check the folders to see your organized files.
    • To exit the script, choose the [Q]uit action.

Example Usage

Let's take a look at some example files and walk through Flag2Folder's functionality with them.

The Files

Flag2Folder works with any file type, but for simplicity we're using these 6 hypothetical text files:

f1_abc.txt
f1_def.txt
f1_ghi.txt
f2_abc.txt
f2_def.txt
f2_ghi.txt

Any part of the file's name can be considered a flag. Here, the files are distinctly labeled with "f1" and "f2" as clear examples of flags, but you could also use any part of the file name, such as "abc" or even "_".

Adding a Flag/Folder Pair

Suppose you want to sort the files with "f1" in their name into a folder called Flag 1 and "f2" into a folder called Flag 2.

We can do this by running the [A]dd option and entering the following:

Enter the flag(s) to look for in filenames: f1
Enter the folder name to pair with the flag(s): Flag 1

Again, but this time for the second flag:

Enter the flag(s) to look for in filenames: f2
Enter the folder name to pair with the flag(s): Flag 2

Why do we need to run it twice? Flag2Folder maintains a many-to-one relationship between its flags and folders. This means that one or more flags can only lead to one folder.

You should now see the following:

Current flag/folder pairs:
  Flag: 'f1' -> Folder: 'Flag 1'
  Flag: 'f2' -> Folder: 'Flag 2'

Execution

Now that you have your desired flag and folder pairs, you can simply choose the [E]xecute action and Flag2Folder will organize your files for you!

Note that this action is irreversible! A preview of the file structure is provided for you to double-check before executing.

Once you do, notice that now the file structure has changed. Instead of 6 text files, you now have 2 folders, Flag 1 and Flag 2, inside of which you have their corresponding files.

Flag 1
  - f1_abc.txt
  - f1_def.txt
  - f1_ghi.txt
Flag 2
  - f2_abc.txt
  - f2_def.txt
  - f2_ghi.txt

flag2folder's People

Contributors

norman-codes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.