🇬🇧 English Version | 🇷🇺 Русская Версия
This Python script generates a visual representation of the filesystem tree in a specified directory and saves it to a text file. The script allows for various configurations to skip or ignore certain directories and files based on patterns.
- Generate a filesystem tree for a specified directory.
- Skip directories based on specific patterns.
- Ignore files or directories using customizable patterns.
- Exception handling for specific files or directories.
- Python 3.x
Clone the repository:
git clone https://github.com/kirrishima/filesystem-tree-generator
Navigate to the project directory:
cd filesystem-tree-generator
Configure the script in the config
dictionary to suit your needs.
file_path
: The name of the file where the tree will be saved.skip_content_folders
: Folders whose contents will be skipped.ignore_patterns
: Folders and files that will be skipped (usesfnmatch
patterns).hard_ignores
: Similar toignore_patterns
, but bypasses exceptions.exceptions
: Files or folders that will not be ignored despite matching ignore patterns.
Then, run the script:
python generate_tree.py
config = {
"file_path": "filesystem_tree.txt",
"skip_content_folders": [
"folder1/subfolder",
"folder2/subfolder"
],
"ignore_patterns": [
".git", "*.pyc", "__pycache__"
],
"hard_ignores": [
"*.log", "*.tmp"
],
"exceptions": [
"important_folder"
]
}
folder
├── fd — копия.py
├── file.txt
├── filesystem_tree.txt
├── folder1
│ └── subfolder
│ └── ◯ ◯ ◯
├── folder2
│ └── subfolder
│ └── ◯ ◯ ◯
└── folder3
├── file.txt
└── subfolder
└── file.txt
The generated filesystem tree will be saved in the file specified in the file_path
configuration, typically filesystem_tree.txt
.
Этот скрипт на Python генерирует визуальное представление дерева файловой системы в указанной директории и сохраняет его в текстовый файл. Скрипт позволяет настроить различные параметры для пропуска или игнорирования определённых директорий и файлов на основе шаблонов.
- Генерация дерева файловой системы для указанной директории.
- Пропуск директорий на основе определённых шаблонов.
- Игнорирование файлов или директорий с использованием настраиваемых шаблонов.
- Обработка исключений для определённых файлов или директорий.
- Python 3.x
Клонируйте репозиторий:
git clone https://github.com/kirrishima/filesystem-tree-generator
Перейдите в каталог проекта:
cd filesystem-tree-generator
Настройте скрипт в словаре config
в соответствии с вашими потребностями.
file_path
: Название файла, в который будет сохранено дерево.skip_content_folders
: Папки, содержимое которых будет пропущено.ignore_patterns
: Папки и файлы, которые будут пропущены (используются шаблоныfnmatch
).hard_ignores
: Аналогичноignore_patterns
, но игнорирует исключения.exceptions
: Файлы или папки, которые не будут проигнорированы, даже если совпадают с шаблонами игнорирования.
Затем запустите скрипт:
python generate_tree.py
config = {
"file_path": "filesystem_tree.txt",
"skip_content_folders": [
"folder1/subfolder",
"folder2/subfolder"
],
"ignore_patterns": [
".git", "*.pyc", "__pycache__"
],
"hard_ignores": [
"*.log", "*.tmp"
],
"exceptions": [
"important_folder"
]
}
folder
├── fd — копия.py
├── file.txt
├── filesystem_tree.txt
├── folder1
│ └── subfolder
│ └── ◯ ◯ ◯
├── folder2
│ └── subfolder
│ └── ◯ ◯ ◯
└── folder3
├── file.txt
└── subfolder
└── file.txt
Сгенерированное дерево файловой системы будет сохранено в файле, указанном в конфигурации file_path
, обычно filesystem_tree.txt
.