|
|
@@ -9,8 +9,9 @@ QFU is a powerful filesystem utility that provides efficient file operations thr
|
|
|
### Key Features
|
|
|
|
|
|
- **File Cloning**: Clone source files to multiple destinations with various options
|
|
|
-- **Auto-Generation**: Automatically generate multiple copies with sequential naming using count parameter
|
|
|
-- **Flexible Input Methods**: Support for direct file specification, auto-generation, or file list input
|
|
|
+- **Directory Cleaning**: Remove files or directories with pattern matching and recursive options
|
|
|
+- **Image Analysis**: List image files with detailed metadata including dimensions, resolution, and file size
|
|
|
+- **Flexible Input Methods**: Support for direct file specification or file list input
|
|
|
- **Path Management**: Automatic directory creation when needed
|
|
|
- **Force Operations**: Override existing files when necessary
|
|
|
- **Robust Error Handling**: Comprehensive validation and error reporting
|
|
|
@@ -20,8 +21,8 @@ QFU is a powerful filesystem utility that provides efficient file operations thr
|
|
|
|
|
|
The application follows a clean modular architecture:
|
|
|
|
|
|
-- **Commands**: Core operations (currently `clone`)
|
|
|
-- **Aspects**: Reusable functionality components (Source, Files, List, Force)
|
|
|
+- **Commands**: Core operations (`clone`, `cleardir`, `img_list`)
|
|
|
+- **Aspects**: Reusable functionality components (Source, Files, List, Force, Filter, Exclude, etc.)
|
|
|
- **Base Classes**: Shared functionality and abstractions
|
|
|
- **Dependency Injection**: Uses `System.IO.Abstractions` for testable file operations
|
|
|
|
|
|
@@ -58,18 +59,60 @@ Clone a source file to one or more destination files.
|
|
|
**Syntax:**
|
|
|
```
|
|
|
qfu clone <source_file> <target_files> [options]
|
|
|
-qfu clone <source_file> -n <count> [options]
|
|
|
```
|
|
|
|
|
|
**Arguments:**
|
|
|
- `source_file`: Path to the source file to clone
|
|
|
-- `target_files`: Pipe-separated list of target file paths (`file1.txt|file2.txt|file3.txt`) - ignored when using `-n`
|
|
|
+- `target_files`: Pipe-separated list of target file paths (`file1.txt|file2.txt|file3.txt`)
|
|
|
|
|
|
**Options:**
|
|
|
-- `-n <count>`: Generate the specified number of files automatically with sequential naming (e.g., `file_1.ext`, `file_2.ext`)
|
|
|
- `-pe` or `-path_ensure`: Create destination directories if they don't exist
|
|
|
- `-force`: Overwrite existing destination files
|
|
|
- `-list`: Treat the first target file as a text file containing a list of destination paths (one per line)
|
|
|
+- `-n <count>`: Generate N numbered copies instead of using target files list
|
|
|
+
|
|
|
+#### Clear Directory Command
|
|
|
+
|
|
|
+Remove files or directories from a specified directory with optional pattern matching.
|
|
|
+
|
|
|
+**Syntax:**
|
|
|
+```
|
|
|
+qfu cleardir <scope> <directory> [options]
|
|
|
+```
|
|
|
+
|
|
|
+**Arguments:**
|
|
|
+- `scope`: Either `files` or `directories` - what to clean
|
|
|
+- `directory`: Path to the directory to clean
|
|
|
+
|
|
|
+**Options:**
|
|
|
+- `-s`: Include subdirectories in the operation
|
|
|
+- `-f <patterns>`: Filter patterns (pipe-separated, e.g., `*.txt|*.log`)
|
|
|
+- `-dry`: Dry run - show what would be deleted without actually deleting
|
|
|
+- `-empty`: Only delete empty files or directories
|
|
|
+
|
|
|
+#### Image List Command
|
|
|
+
|
|
|
+List all image files from a directory with their dimensions, resolution, and size information.
|
|
|
+
|
|
|
+**Syntax:**
|
|
|
+```
|
|
|
+qfu img_list <source> [options]
|
|
|
+```
|
|
|
+
|
|
|
+**Arguments:**
|
|
|
+- `source`: Path to directory to scan for image files
|
|
|
+
|
|
|
+**Options:**
|
|
|
+- `-s`: Include subdirectories in the scan
|
|
|
+- `-exclude <patterns>`: Exclude files matching patterns (pipe-separated, e.g., `*.tmp|backup*`)
|
|
|
+
|
|
|
+**Output Format:**
|
|
|
+```
|
|
|
+Dimensions Resolution Size File Path
|
|
|
+------------ --------------- --------- --------------------------------------------------
|
|
|
+1920x1080 72x72 DPI 2.5 MB photos/vacation.jpg
|
|
|
+800x600 96x96 DPI 145.2 KB thumbnails/small.png
|
|
|
+```
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
@@ -77,44 +120,46 @@ qfu clone <source_file> -n <count> [options]
|
|
|
```bash
|
|
|
# Clone a file to multiple destinations
|
|
|
qfu clone source.txt "backup1.txt|backup2.txt|backup3.txt"
|
|
|
-```
|
|
|
|
|
|
-#### Clone with Path Creation
|
|
|
-```bash
|
|
|
-# Clone and create destination directories if needed
|
|
|
-qfu clone template.config "configs/dev.config|configs/staging.config|configs/prod.config" -pe
|
|
|
+# Generate 5 numbered copies
|
|
|
+qfu clone template.txt dummy -n 5
|
|
|
+# Creates: template_1.txt, template_2.txt, template_3.txt, template_4.txt, template_5.txt
|
|
|
```
|
|
|
|
|
|
-#### Force Overwrite Existing Files
|
|
|
+#### Directory Cleaning
|
|
|
```bash
|
|
|
-# Overwrite existing destination files
|
|
|
-qfu clone master.template "project1/config.xml|project2/config.xml" -force -pe
|
|
|
-```
|
|
|
+# Remove all .log and .tmp files from current directory
|
|
|
+qfu cleardir files . -f "*.log|*.tmp"
|
|
|
|
|
|
-#### Using File Lists
|
|
|
-```bash
|
|
|
-# Create a file list first
|
|
|
-echo "backup/file1.txt" > targets.txt
|
|
|
-echo "backup/file2.txt" >> targets.txt
|
|
|
-echo "backup/file3.txt" >> targets.txt
|
|
|
+# Remove empty directories recursively (dry run first)
|
|
|
+qfu cleardir directories ./temp -s -empty -dry
|
|
|
|
|
|
-# Use the list file for cloning
|
|
|
-qfu clone source.txt targets.txt -list -pe
|
|
|
+# Remove all files from subdirectories
|
|
|
+qfu cleardir files ./cache -s -force
|
|
|
```
|
|
|
|
|
|
-#### Auto-Generate Multiple Files
|
|
|
+#### Image Analysis
|
|
|
```bash
|
|
|
-# Generate 5 copies with sequential naming (source_1.txt, source_2.txt, etc.)
|
|
|
-qfu clone source.txt -n 5
|
|
|
+# List all images in current directory
|
|
|
+qfu img_list .
|
|
|
|
|
|
-# Generate 3 copies with force and path creation
|
|
|
-qfu clone template.config -n 3 -force -pe
|
|
|
+# List images recursively, excluding thumbnails and temporary files
|
|
|
+qfu img_list ./photos -s -exclude "thumb*|*.tmp|backup*"
|
|
|
+
|
|
|
+# Scan project directory but exclude build artifacts
|
|
|
+qfu img_list ./src -s -exclude "bin/*|obj/*|*.cache"
|
|
|
```
|
|
|
|
|
|
-#### Complex Example
|
|
|
+#### Complex Examples
|
|
|
```bash
|
|
|
-# Clone with all options (manual file specification)
|
|
|
+# Clone with all options
|
|
|
qfu clone template.cs "src/Class1.cs|src/Class2.cs|tests/TestClass.cs" -force -pe
|
|
|
+
|
|
|
+# Clean directories with complex patterns
|
|
|
+qfu cleardir files ./downloads -s -f "*.tmp|temp*|cache*" -dry
|
|
|
+
|
|
|
+# Comprehensive image analysis
|
|
|
+qfu img_list ./media -s -exclude "*.psd|raw/*|backup*"
|
|
|
```
|
|
|
|
|
|
### Return Codes
|
|
|
@@ -130,24 +175,32 @@ QFU provides detailed progress information:
|
|
|
- Final success/failure count
|
|
|
- Detailed error messages for failed operations
|
|
|
|
|
|
-Example output:
|
|
|
-```
|
|
|
-Will be cloning file 'source.txt' to 3 files (with force)...
|
|
|
-[1] Cloned 'source.txt' to 'dest1.txt' successfully.
|
|
|
-[2] File 'dest2.txt' already exists. Skipping clone operation.
|
|
|
-[3] Cloned 'source.txt' to 'dest3.txt' successfully.
|
|
|
-Successfully cloned: 2 of 3 files.
|
|
|
-```
|
|
|
+## Supported Image Formats
|
|
|
+
|
|
|
+The `img_list` command supports the following image formats:
|
|
|
+- **JPEG** (.jpg, .jpeg)
|
|
|
+- **PNG** (.png)
|
|
|
+- **GIF** (.gif)
|
|
|
+- **BMP** (.bmp)
|
|
|
+- **TIFF** (.tiff, .tif)
|
|
|
+- **WebP** (.webp)
|
|
|
+- **ICO** (.ico)
|
|
|
+- **SVG** (.svg)
|
|
|
+- **PSD** (.psd)
|
|
|
+- **RAW formats** (.raw, .cr2, .nef, .arw)
|
|
|
+
|
|
|
+Note: Some formats may show "N/A" for dimensions/resolution if they cannot be processed by the image library.
|
|
|
|
|
|
## Error Handling
|
|
|
|
|
|
QFU provides comprehensive error handling:
|
|
|
|
|
|
-- **Source Validation**: Verifies source file exists before operation
|
|
|
-- **Destination Validation**: Checks for existing files (unless `-force` used)
|
|
|
+- **Source Validation**: Verifies source files/directories exist before operation
|
|
|
+- **Destination Validation**: Checks for existing files (unless `--force` used)
|
|
|
- **Path Validation**: Ensures destination paths are valid
|
|
|
- **Permission Checking**: Reports access denied errors
|
|
|
-- **List File Validation**: Validates list files when using `-list` option
|
|
|
+- **Image Processing**: Graceful handling of unsupported or corrupted image files
|
|
|
+- **Pattern Validation**: Validates search and exclude patterns
|
|
|
|
|
|
## Development
|
|
|
|
|
|
@@ -158,11 +211,19 @@ qfu/
|
|
|
├── Commands/
|
|
|
│ ├── BaseCmd.cs # Base command functionality
|
|
|
│ ├── CloneCmd.cs # Clone command implementation
|
|
|
+│ ├── ClearDirCmd.cs # Directory cleaning command
|
|
|
+│ ├── ImgListCmd.cs # Image listing command
|
|
|
│ └── Aspects/
|
|
|
-│ ├── FilesAspect.cs # File handling logic
|
|
|
-│ ├── ForceAspect.cs # Force operation logic
|
|
|
-│ ├── ListAspect.cs # List file processing
|
|
|
-│ └── SourceAspect.cs # Source file validation
|
|
|
+│ ├── FilesAspect.cs # File handling logic
|
|
|
+│ ├── ForceAspect.cs # Force operation logic
|
|
|
+│ ├── ListAspect.cs # List file processing
|
|
|
+│ ├── SourceAspect.cs # Source file validation
|
|
|
+│ ├── FilterAspect.cs # Pattern filtering
|
|
|
+│ ├── ExcludeAspect.cs # Exclusion patterns
|
|
|
+│ ├── ScopeAspect.cs # Operation scope (files/dirs)
|
|
|
+│ ├── SubdirsAspect.cs # Subdirectory inclusion
|
|
|
+│ ├── DryAspect.cs # Dry run functionality
|
|
|
+│ └── EmptyAspect.cs # Empty file/directory handling
|
|
|
├── QfuCommandContext.cs # Command execution context
|
|
|
├── QfuEngineContext.cs # Engine context
|
|
|
└── Program.cs # Application entry point
|
|
|
@@ -179,6 +240,13 @@ qfu/
|
|
|
|
|
|
The project uses `System.IO.Abstractions` for testable file operations. Mock the `IFileSystem` interface for unit testing.
|
|
|
|
|
|
+## Dependencies
|
|
|
+
|
|
|
+- **.NET 9.0**: Core runtime
|
|
|
+- **qdr.fnd.core.qconsole**: Command-line framework
|
|
|
+- **System.Drawing.Common**: Image processing capabilities
|
|
|
+- **System.IO.Abstractions**: File system abstraction for testing
|
|
|
+
|
|
|
## License
|
|
|
|
|
|
Copyright © 2025 Quadarax
|