### Full Location Options Example Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Demonstrates all available options for configuring a location, including depth, search type, and exclusion/inclusion filters. Use this for fine-grained control over file searching. ```yaml rules: - locations: - path: ... min_depth: ... max_depth: ... search: ... exclude_files: ... exclude_dirs: ... system_exclude_files: ... system_exclude_dirs: ... ignore_errors: ... filter: ... filter_dirs: ... ``` -------------------------------- ### Organize Rule Options Example Source: https://github.com/tfeldmann/organize/blob/main/docs/rules.md Illustrates the various options available for defining a rule, such as name, enabled status, targets, locations, filters, and actions. ```yaml rules: # First rule - name: ... enabled: ... targets: ... locations: ... subfolders: ... filter_mode: ... filters: ... actions: ... tags: ... # Another rule - name: ... enabled: ... # ... and so on ``` -------------------------------- ### Show Content of PDF Files Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md This example demonstrates how to display the content of all PDF files in a specified location. It requires both the 'extension' and 'filecontent' filters. ```yaml rules: - name: "Show the content of all your PDF files" locations: ~/Documents filters: - extension: pdf - filecontent actions: - echo: "{filecontent}" ``` -------------------------------- ### Install organize-tool Source: https://github.com/tfeldmann/organize/blob/main/README.md Install or update the organize-tool package using pip. This command ensures you have the latest version. ```bash pip install -U organize-tool ``` -------------------------------- ### Echo File Details Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Prints the file extension and name for each file on the desktop, formatted as 'Found a [EXTENSION]: "[NAME]"'. This example demonstrates dynamic message formatting. ```yaml rules: - locations: - "~/Desktop" filters: - extension - name actions: - echo: 'Found a {extension.upper()}: "{name}"' ``` -------------------------------- ### Basic Rule Configuration Source: https://github.com/tfeldmann/organize/blob/main/README.md Define a rule to find PDF files in the Downloads folder and display a message. This is a starting point for file organization. ```yaml rules: - name: "Find PDFs" locations: - ~/Downloads subfolders: true filters: - extension: pdf actions: - echo: "Found PDF!" ``` -------------------------------- ### Match Invoice with Regex Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use a regular expression to match filenames. This example filters for invoice files with a specific pattern. ```yaml rules: - locations: "~/Desktop" filters: - regex: '^RG(\d{12})-sig\.pdf$' actions: - move: "~/Documents/Invoices/1und1/" ``` -------------------------------- ### Match files starting with 'Invoice' Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use the 'name' filter with 'startswith' to match files beginning with a specific prefix. This is case-sensitive by default. ```yaml rules: - locations: "~/Desktop" filters: - name: startswith: Invoice actions: - echo: "This is an invoice" ``` -------------------------------- ### Trash Large Downloads by Size Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files based on size to trash large downloads. This example targets files larger than 0.5 GB in the Downloads folder. ```yaml rules: - locations: "~/Downloads" targets: files filters: - size: "> 0.5 GB" actions: - trash ``` -------------------------------- ### Migrating v1 to v2: Move action configuration Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md In v2, the `move` action supports conflict resolution. The example shows `on_conflict: rename_new` and `rename_template`. ```yaml rules: - locations: ~/Desktop filters: - extension: pdf actions: - move: dest: ~/Documents/PDFs/ on_conflict: rename_new rename_template: "{name}-{counter}{extension}" ``` -------------------------------- ### Filter Filename by Date Code Regex Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md This example filters files whose filenames start with a date code in the format YYYY-MM-DD. It uses a regular expression to capture the year. ```yaml rules: - locations: ~/Desktop filters: - regex: '(?P20\d{2})-[01]\d-[0123]\d.*' actions: - echo: "Year: {regex.year}" ``` -------------------------------- ### Show Available EXIF Data Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md The 'exif' filter can be used to display available EXIF data from image files. This example shows how to echo all EXIF data for images in a specified directory. ```yaml rules: - name: "Show available EXIF data of your pictures" locations: - path: "~/Pictures" max_depth: null filters: - exif actions: - echo: "{exif}" ``` -------------------------------- ### Move JPEGs by Size Range and Keep Path Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Move JPEG files within a specific size range while preserving their relative directory structure. This example moves files between 1MB and 10MB. ```yaml rules: - locations: - path: "~/Pictures" max_depth: null filters: - extension: - jpg - jpeg - size: ">1mb, <10mb" actions: - move: "~/Pictures/sorted/{relative_path}/" ``` -------------------------------- ### Extract and Rename with Regex Named Groups Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Extract data from filenames using regex named groups to rename files. This example uses the 'the_number' named group to include the invoice number in the destination path. ```yaml rules: - locations: ~/Desktop filters: - regex: '^RG(?P\d{12})-sig\.pdf$' actions: - move: ~/Documents/Invoices/1und1/{regex.the_number}.pdf ``` -------------------------------- ### Copy Images with GPS Information Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter images based on the presence of GPS information using the 'exif:gps.gpsdate' filter. This example copies images containing GPS data to a new location while preserving the subfolder structure. ```yaml rules: - name: "GPS demo" locations: - path: "~/Pictures" max_depth: null filters: - exif: gps.gpsdate actions: - copy: "~/Pictures/with_gps/{relative_path}/" ``` -------------------------------- ### Filter Images by Camera Manufacturer Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use the 'exif' filter with specific metadata keys like 'image.model' to filter images from particular camera models. This example moves images taken with a Nikon D3200 to a dedicated folder. ```yaml rules: - name: "Filter by camera manufacturer" locations: - path: "~/Pictures" max_depth: null filters: - exif: image.model: Nikon D3200 actions: - move: "~/Pictures/My old Nikon/" ``` -------------------------------- ### Echo Hello World with File Path Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Prints 'Hello World!' along with the file path for every file found on the Desktop. This is useful for basic file system traversal and logging. ```yaml rules: - locations: - "~/Desktop" actions: - echo: "Hello World! {path}" ``` -------------------------------- ### Show Configuration Path Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Display the path to the default configuration file or just the full path. ```sh organize show organize show --path # show the full path to the default config ``` -------------------------------- ### Run or Simulate Configuration Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Execute or simulate the default configuration file or a specific configuration file. ```sh organize sim organize run organize sim [FILE] organize run [FILE] ``` -------------------------------- ### Test the Organize Docker Image Source: https://github.com/tfeldmann/organize/blob/main/docs/docker.md Run the built Docker image without any arguments to display its usage help text and confirm it's working correctly. ```sh docker run organize ``` -------------------------------- ### Organize CLI Usage Source: https://github.com/tfeldmann/organize/blob/main/README.md This is the main help output for the organize CLI. It outlines the available commands and their general usage patterns. ```txt organize - The file management automation tool. Usage: organize run [options] [] organize sim [options] [] organize new [] organize edit [] organize check [] organize debug [] organize show [--path|--reveal] [] organize list organize docs organize --version organize --help Commands: run Organize your files. sim Simulate organizing your files. new Creates a new config. edit Edit the config file with $EDITOR. check Check whether the config file is valid. debug Shows the raw config parsing steps. show Print the config to stdout. Use --reveal to reveal the file in your file manager Use --path to show the path to the file list Lists config files found in the default locations. docs Open the documentation. Options: A config name or path to a config file -W --working-dir The working directory -F --format (default|jsonl) The output format [Default: default] -T --tags Tags to run (eg. "initial,release") -S --skip-tags Tags to skip -h --help Show this help page. ``` -------------------------------- ### Using Placeholders for File Size and Hash Source: https://github.com/tfeldmann/organize/blob/main/docs/rules.md Demonstrates how to use placeholders like {size} and {hash} within actions, which are populated by the specified filters. ```yaml rules: - locations: ~/Desktop filters: - size - hash actions: - echo: "{size} {hash}" ``` -------------------------------- ### Migrating CLI: reveal to show --reveal Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md The `organize reveal` command is now `organize show --reveal` in v3. ```bash organize show --reveal ``` -------------------------------- ### Build the Organize Docker Image Source: https://github.com/tfeldmann/organize/blob/main/docs/docker.md Build the Docker image by navigating to the directory containing the Dockerfile and running the build command. The image will be tagged as 'organize'. ```sh docker build -t organize . ``` -------------------------------- ### Migrating CLI: reveal --path to show --path Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md The `organize reveal --path` command is now `organize show --path` in v3. ```bash organize show --path ``` -------------------------------- ### Running Organize with a Specific Working Directory Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Demonstrates how to execute the organize command with a specified working directory, which affects how relative locations are resolved. Use this to test or run rules in different contexts. ```sh organize sim huge-pic-warner.yaml --working-dir=some/other/dir/ ``` -------------------------------- ### Pass Organize Configuration via Stdin Source: https://github.com/tfeldmann/organize/blob/main/docs/docker.md Run the organize container and pass the configuration file content via standard input using the '-i' flag and the 'check --stdin' command. This is an alternative to mounting the config file. ```sh docker run -i organize check --stdin < ./docker-conf.yml ``` -------------------------------- ### Check Configuration Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Validate the configuration file. Use the --debug flag for more detailed output. ```sh organize check organize check --debug # check with debug output ``` -------------------------------- ### Run Organize with Mounted Config and Data Source: https://github.com/tfeldmann/organize/blob/main/docs/docker.md Execute the organize container, mounting a local configuration file to '/config/config.yml' and the current directory to '/data'. This allows organize to process files in the mounted data directory using the specified rules. ```sh docker run -v ./docker-conf.yml:/config/config.yml -v .:/data organize run ``` -------------------------------- ### Combining Multiple YAML Aliases Source: https://github.com/tfeldmann/organize/blob/main/docs/rules.md Illustrates how to combine multiple YAML aliases to create a comprehensive list of locations for rules, demonstrating flexibility in configuration. ```yaml private_folders: &private - "/path/private" - "~/path/private" work_folders: &work - "/path/work" - "~/My work folder" all_folders: &all - *private - *work rules: - locations: *private filters: ... actions: ... - locations: *work filters: ... actions: ... - locations: *all filters: ... actions: ... # same as *all - locations: - *work - *private filters: ... actions: ... ``` -------------------------------- ### Migrating v1 to v2: Including system files Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md To include system files in v2, override `system_exclude_files` and `system_exclude_dirs` with empty lists in the location configuration. ```yaml rules: - locations: - path: ~/Desktop/ system_exclude_files: [] system_exclude_dirs: [] filters: - name: .DS_Store actions: - trash ``` -------------------------------- ### Copy Files with Placeholder Destination and Overwrite Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Copy files based on their extension into corresponding folders (e.g., PDF to 'PDF', JPG to 'JPG'). Existing files with the same name will be overwritten. ```yaml rules: - locations: ~/Desktop filters: - extension: - pdf - jpg actions: - copy: dest: "~/Desktop/{extension.upper()}/" on_conflict: overwrite ``` -------------------------------- ### Echo Relative and Absolute Paths Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Displays both the absolute path and the relative path for all files within '~/Downloads', '~/Desktop', and their subfolders, up to any depth. This helps in understanding file locations within the directory structure. ```yaml rules: - locations: - path: ~/Desktop max_depth: null - path: ~/Downloads max_depth: null actions: - echo: "Path: {path}" - echo: "Relative: {relative_path}" ``` -------------------------------- ### YAML Alias for Multiple Folders Source: https://github.com/tfeldmann/organize/blob/main/docs/rules.md Shows how to define a YAML alias for a list of folders and then reference it in multiple rules to avoid repetition. ```yaml all_my_messy_folders: &all - ~/Desktop - ~/Downloads - ~/Documents - ~/Dropbox rules: - locations: *all filters: ... actions: ... - locations: *all filters: ... actions: ... ``` -------------------------------- ### Migrating Placeholder Syntax: now() Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md In v3, use `{now()}` for the current timestamp instead of the deprecated `{now}`. ```yaml "{now()}" ``` -------------------------------- ### Execute Shell Command with Organize Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Use the 'shell' action to execute a command on files that match the rules. The '{path}' variable can be used to reference the file path. ```yaml rules: - name: "On macOS: Open all pdfs on your desktop" locations: "~/Desktop" filters: - extension: pdf actions: - shell: 'open "{path}"' ``` -------------------------------- ### Select Rules by Tags Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Use command-line options to select or skip rules based on their tags. Tags can be provided as a comma-separated list. ```sh organize sim --tags=debug,foo --skip-tags=slow ``` -------------------------------- ### Show file hashes and sizes Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use the 'hash' and 'size' filters to display the hash and decimal size of files in a specified location. ```yaml rules: - name: "Show the hashes and size of your files" locations: "~/Desktop" filters: - hash - size actions: - echo: "{hash} {size.decimal}" ``` -------------------------------- ### Specify Working Directory Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md When running or simulating a specific configuration file, you can optionally specify the working directory. ```sh organize sim [FILE] --working-dir=~/Documents ``` -------------------------------- ### Basic Location Definition Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Defines a single directory path where organize will search for files. ```yaml rules: - locations: ~/Desktop actions: ... ``` -------------------------------- ### Write Custom Text to File with Organize Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md The 'write' action allows you to append or prepend custom text to a specified output file. You can use template variables like '{size.traditional}' and '{relative_path}' to include file information. The 'clear_before_first_write' option can be set to true to overwrite the file before the first write. ```yaml rules: - name: "Record file sizes" locations: ~/Downloads filters: - size actions: - write: outfile: "./sizes.txt" text: "{size.traditional} -- {relative_path}" mode: "append" clear_before_first_write: true ``` ```yaml rules: - name: "File sizes by extension" locations: ~/Downloads filters: - size - extension actions: - write: outfile: "./sizes.{extension}.txt" text: "{size.traditional} -- {relative_path}" mode: "prepend" clear_before_first_write: true ``` -------------------------------- ### Using Extension Lists with Aliases Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Leverage YAML aliases to define and reuse lists of file extensions, making configurations more maintainable and readable. ```yaml img_ext: &img - png - jpg - tiff audio_ext: &audio - mp3 - wav - ogg rules: - name: "Using extension lists" locations: "~/Desktop" filters: - extension: - *img - *audio actions: - echo: "Found media file: {path}" ``` -------------------------------- ### Parallelize Organize Jobs Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Run multiple organize processes simultaneously on different configuration files for faster processing. Ensure configurations are independent. ```sh organize run config_1.yaml & organize run config_2.yaml & organize run config_3.yaml & ``` -------------------------------- ### Migrating CLI: check --debug to debug Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md The `organize check --debug` command has been simplified to `organize debug` in v3. ```bash organize debug ``` -------------------------------- ### Edit Configuration File Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Open the default configuration file in your editor or a specified editor. You can also set the EDITOR environment variable. ```sh organize edit # opens in $EDITOR organize edit --editor=vim EDITOR=code organize edit ``` -------------------------------- ### Minimal Organize Rule Configuration Source: https://github.com/tfeldmann/organize/blob/main/docs/rules.md This is the most basic configuration for an organize rule. It specifies a location and a simple action to be executed. ```yaml rules: - locations: "~/Desktop" actions: - echo: "Hello World!" ``` -------------------------------- ### Migrating v1 to v2: Placeholder date formatting Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md In v2, use Jinja templating for date formatting. Replace `{created.year}-{created.month:02}-{created.day:02}` with `{created.strftime('%Y-%m-%d')}`. ```yaml "{created.strftime('%Y-%m-%d')}" ``` -------------------------------- ### Migrating v1 to v2: Left padding numbers with format Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md Alternatively, use the `.format()` method for left-padding numbers in v2: `'{' '{:02}'.format(your_variable) '}'`. ```yaml "{ '{:02}'.format(your_variable) }" ``` -------------------------------- ### Move Files with Placeholder Destination and Overwrite Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Moves files to a destination folder dynamically determined by their extension, overwriting existing files. The 'dest' parameter uses a placeholder '{extension.upper()}' to create subfolders for each file type. ```yaml rules: - locations: ~/Desktop filters: - extension: - pdf - jpg actions: - move: dest: "~/Desktop/{extension.upper()}/" on_conflict: "overwrite" ``` -------------------------------- ### Python Scripting with Basic File Path Access Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Use this action to execute Python code. It provides access to the current file's path and allows for basic loop operations. ```yaml rules: - locations: "~/Desktop" actions: - python: | print('The path of the current file is %s' % path) for _ in range(5): print('Heyho, its me from the loop') ``` -------------------------------- ### Migrating v1 to v2: Left padding numbers with modulo Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md For left-padding numbers in v2, use the modulo operator: `'{'%'02d' % your_variable}'`. ```yaml "{'%'02d' % your_variable}" ``` -------------------------------- ### Poppler Directory Structure on Windows Source: https://github.com/tfeldmann/organize/blob/main/docs/textract-hints.md This illustrates the expected directory structure after extracting and placing Poppler files into the 'C:\Program Files\Poppler' directory on a Windows system. ```text C:\Program Files\Poppler \bin \include \lib \share ``` -------------------------------- ### Migrating Placeholder Syntax: utcnow() Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md In v3, use `{utcnow()}` for the current UTC timestamp instead of the deprecated `{utcnow}`. ```yaml "{utcnow()}" ``` -------------------------------- ### Advanced File Organization and Backup Source: https://github.com/tfeldmann/organize/blob/main/README.md An advanced rule that searches recursively through local directories and an FTP server for PDF or DOCX files. It prompts for user confirmation, moves files based on extension and creation date, and creates a zip backup. Files are renamed if a conflict occurs. ```yaml rules: - name: "Download, cleanup and backup" locations: - path: ~/Documents max_depth: 3 - path: ftps://demo:demo@demo.wftpserver.com filters: - extension: - pdf - docx - created actions: - confirm: msg: "Really continue?" default: true - move: dest: "~/Documents/{extension.upper()}/{created.strftime('%Y-%m')}/" on_conflict: rename_new - copy: "zip:///Users/thomas/Desktop/backup.zip" ``` -------------------------------- ### List file macOS tags Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Retrieve and display all macOS tags associated with a file. ```yaml rules: - name: "Listing file tags" locations: "~/Downloads" filters: - macos_tags actions: - echo: "{macos_tags}" ``` -------------------------------- ### Exclude Filters with 'not' Prefix and 'filter_mode' Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Demonstrates how to exclude specific filters using the 'not' prefix and how to exclude all filters by setting 'filter_mode' to 'none'. ```yaml rules: # using filter_mode - locations: ~/ filter_mode: "none" # <- excludes all filters: - empty - name: endswith: "2022" actions: - echo: "{name}" # Exclude a single filter - locations: ~/ filters: - not extension: jpg # <- matches all non-jpgs - name: startswith: "Invoice" - not empty # <- matches files with content actions: - echo: "{name}" ``` -------------------------------- ### Add Templated macOS Tag with Color Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Creates a tag using a template that includes dynamic information like the creation year, and assigns a color. The '{created.year}' placeholder is replaced with the file's creation year. ```yaml rules: - locations: "~/Documents/Invoices" filters: - created actions: - macos_tags: - Year-{created.year} (red) ``` -------------------------------- ### Python Scripting with YAML Aliases and Simulation Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Execute Python code defined using YAML aliases. The `run_in_simulation` option allows testing without modifying files. ```yaml my_python_script: &script | print("Hello World!") print(path) rules: - name: "Run in simulation and yaml alias" locations: - ~/Desktop/ actions: - python: code: *script run_in_simulation: yes ``` -------------------------------- ### Match files with 'startswith', 'contains', and 'case_sensitive: false' Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Combine 'startswith' and 'contains' criteria for file names, with case-insensitivity enabled. This allows for flexible matching of partial names. ```yaml rules: - locations: "~/Desktop" filters: - name: startswith: A contains: hole case_sensitive: false actions: - echo: "Found a match." ``` -------------------------------- ### Copy Files with Placeholder Destination and Deduplication Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Copy files into extension-specific folders. If duplicates are found, the second file will be renamed. Non-duplicate files with the same name are handled by renaming the second file. ```yaml rules: - locations: ~/Desktop filters: - extension: - pdf - jpg actions: - copy: dest: "~/Desktop/{extension.upper()}/" on_conflict: deduplicate ``` -------------------------------- ### Display Creation Date in Different Formats Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filters PDF files and displays their creation date in ISO format and as a Unix timestamp. The 'created' filter must be enabled. ```yaml rules: - name: Display the creation date locations: "~/Documents" filters: - extension: pdf - created actions: - echo: "ISO Format: {created.strftime('%Y-%m-%d')}" - echo: "As timestamp: {created.timestamp() | int}" ``` -------------------------------- ### Move Files to Trash with Organize Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md The 'trash' action moves files matching the specified filters to the system's trash. This is useful for safely deleting files that are older than a certain period or match specific extensions. ```yaml rules: - name: Move all JPGs and PNGs on the desktop which are older than one year into the trash locations: "~/Desktop" filters: - lastmodified: years: 1 mode: older - extension: - png - jpg actions: - trash ``` -------------------------------- ### Match files with multiple 'startswith', 'contains', and 'endswith' Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use multiple criteria including 'startswith', 'contains', and 'endswith' for file name matching, with case-insensitivity. This supports complex pattern matching. ```yaml rules: - locations: "~/Desktop" filters: - name: startswith: - "A" - "B" contains: - "5" - "6" endswith: _end case_sensitive: false actions: - echo: "Found a match." ``` -------------------------------- ### Match Multiple File Extensions Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use this filter to match files with any of the specified multiple file extensions. Ensure extensions are listed correctly. ```yaml rules: - name: "Match multiple file extensions" locations: "~/Desktop" filters: - extension: - .jpg - jpeg actions: - echo: "Found JPG file: {path}" ``` -------------------------------- ### Python Scripting for Web Search Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md This Python action opens a web browser to perform a Google search based on the filename. It requires the `webbrowser` module. ```yaml rules: - locations: ~/Desktop filters: - name: startswith: "_" actions: - python: | import webbrowser webbrowser.open('https://www.google.com/search?q=%s' % name) ``` -------------------------------- ### Add Multiple macOS Tags Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Applies multiple tags to files. List all desired tags under the 'macos_tags' key. Files matching the filters will receive all specified tags. ```yaml rules: - locations: "~/Documents/Invoices" filters: - name: startswith: "Invoice" - extension: pdf actions: - macos_tags: - Important - Invoice ``` -------------------------------- ### Migrating v1 to v2: Extension case conversion Source: https://github.com/tfeldmann/organize/blob/main/docs/migrating.md In v2, use `.upper()` and `.lower()` as functions for extension case conversion: `'{extension.upper()}'` and `'{extension.lower()}'`. ```yaml "{extension.upper()}" ``` ```yaml "{extension.lower()}" ``` -------------------------------- ### Match Invoice with Regex and Sort by Customer Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files based on a regular expression pattern within their content to identify invoices and extract customer information for sorting. ```yaml rules: - name: "Match an invoice with a regular expression and sort by customer" locations: "~/Desktop" filters: - filecontent: 'Invoice.*Customer (?P\w+)' actions: - move: "~/Documents/Invoices/{filecontent.customer}/" ``` -------------------------------- ### Confirm Deletion Action Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Use the 'confirm' action to prompt the user before deleting duplicate files. This is useful for preventing accidental data loss. ```yaml rules: - name: "Delete duplicates with confirmation" locations: - ~/Downloads - ~/Documents filters: - not empty - duplicate - name actions: - confirm: "Delete {name}?" - trash ``` -------------------------------- ### Location with Options (max_depth) Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Defines a location with specific search depth constraints. Use this when you need to control how deep into subdirectories the search should go. ```yaml rules: - name: "Location list" locations: - path:"~/Desktop" max_depth: 3 actions: ... ``` -------------------------------- ### Match Single File Extension Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use this filter to match files with a specific single file extension. ```yaml rules: - name: "Match a single file extension" locations: "~/Desktop" filters: - extension: png actions: - echo: "Found PNG file: {path}" ``` -------------------------------- ### ETH Donation Address Source: https://github.com/tfeldmann/organize/blob/main/README.md This is the Ethereum (ETH) donation address for the project. ```txt 0x8924a060CD533699E230C5694EC95b26BC4168E7 ``` -------------------------------- ### Tag Rules in Configuration Source: https://github.com/tfeldmann/organize/blob/main/docs/configuration.md Define tags within your YAML configuration file to categorize rules. ```yaml rules: - name: My first rule actions: - echo: "Hello world" tags: - debug - fast ``` -------------------------------- ### Using Environment Variables in Locations Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Specifies locations using environment variables for dynamic path resolution. This is useful for configurations that need to adapt to different environments. ```yaml rules: - locations: # via {env} - the "" are important here! - "{env.MY_FOLDER}" # via $ - equal to the one above. - "$MY_FOLDER" # with location options - path: "{env.OTHER_FOLDER}/Inbox/Invoices" max_depth: null actions: - echo: "{path}" ``` -------------------------------- ### Add Move Action to Rule Source: https://github.com/tfeldmann/organize/blob/main/README.md Enhance the existing rule to move found PDF files to a specified directory. This demonstrates a common file management action. ```yaml actions: - echo: "Found PDF!" - move: ~/Documents/PDFs/ ``` -------------------------------- ### Format last modified date output Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Demonstrates formatting the last modified date into ISO format or as a Unix timestamp. ```yaml rules: - name: "Formatting the lastmodified date" locations: "~/Documents" filters: - extension: pdf - lastmodified actions: - echo: "ISO Format: {lastmodified.strftime('%Y-%m-%d')}" - echo: "As timestamp: {lastmodified.timestamp() | int}" ``` -------------------------------- ### Filter Files by Creation Date (Days) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Selects files created at least a specified number of days ago. Ensure the 'created' filter is enabled. ```yaml rules: - name: Show all files on your desktop created at least 10 days ago locations: "~/Desktop" filters: - created: days: 10 actions: - echo: "Was created at least 10 days ago" ``` -------------------------------- ### Sort Invoices and Receipts Source: https://github.com/tfeldmann/organize/blob/main/README.md Moves PDF files containing 'Invoice', 'Order', or 'Purchase' in their name from the Downloads folder to a specified Documents subfolder. Case-insensitive matching is used. ```yaml rules: - name: "Sort my invoices and receipts" locations: ~/Downloads subfolders: true filters: - extension: pdf - name: contains: - Invoice - Order - Purchase case_sensitive: false actions: - move: ~/Documents/Shopping/ ``` -------------------------------- ### BTC Donation Address Source: https://github.com/tfeldmann/organize/blob/main/README.md This is the Bitcoin (BTC) donation address for the project. ```txt 39vpniiZk8qqGB2xEqcDjtWxngFCCdWGjY ``` -------------------------------- ### Echo Message for Old Files Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Finds files older than a year in the Desktop location and echoes a predefined message for each found file. ```yaml rules: - name: "Find files older than a year" locations: ~/Desktop filters: - lastmodified: days: 365 actions: - echo: "Found old file" ``` -------------------------------- ### Filter files by macOS tag (multiple criteria) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Apply filters to select files that match either a specific tag name (any color) or a tag of a specific color. ```yaml rules: - name: "All files with a tag 'Invoice' (any color) or with a green tag" locations: "~/Downloads" filters: - macos_tags: - "Invoice (*)" - "* (green)" actions: - echo: "Match found!" ``` -------------------------------- ### Filter Files by Creation Time (Hours) - Newer Mode Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Selects files created within the last specified number of hours. Use 'mode: newer' for this behavior. ```yaml rules: - name: Show all files on your desktop which were created within the last 5 hours locations: "~/Desktop" filters: - created: hours: 5 mode: newer actions: - echo: "Was created within the last 5 hours" ``` -------------------------------- ### Filter by multiple specific MIME types Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files by a list of specific MIME types, such as 'application/pdf' or 'audio/midi'. This enables matching multiple distinct formats. ```yaml rules: - name: Filter by multiple specific MIME types locations: "~/Music" filters: - mimetype: - application/pdf - audio/midi actions: - echo: "Found Midi or PDF." ``` -------------------------------- ### Specify macOS Tag Colors Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Assigns tags with specific colors to files. Colors are specified in parentheses after the tag name. Ensure the color name is supported. ```yaml rules: - locations: "~/Documents/Invoices" filters: - name: startswith: "Invoice" - extension: pdf actions: - macos_tags: - Important (green) - Invoice (purple) ``` -------------------------------- ### Show MIME types Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use the mimetype filter to display the MIME type of files in a specified location. This is useful for general file inspection. ```yaml rules: - name: "Show MIME types" locations: "~/Downloads" filters: - mimetype actions: - echo: "{mimetype}" ``` -------------------------------- ### Move PDFs by year of last modification Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Organize PDF files by moving them into directories named after the year of their last modification. ```yaml rules: - name: "Sort pdfs by year of last modification" locations: "~/Documents" filters: - extension: pdf - lastmodified actions: - move: "~/Documents/PDF/{lastmodified.year}/" ``` -------------------------------- ### Copy Files to Specific Folder Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Copy all PDF files from the desktop to a specified folder, preserving their original filenames. Ensure the destination folder exists. ```yaml rules: - locations: ~/Desktop filters: - extension: pdf actions: - copy:"~/Desktop/somefolder/" ``` -------------------------------- ### Rename Files: Convert All Extensions to Lowercase Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Converts all file extensions to lowercase. This action applies to all files within the specified locations and uses the captured extension. ```yaml rules: - name: "Convert **all** file extensions to lowercase" locations: "~/Desktop" filters: - name - extension actions: - rename: "{name}.{extension.lower()}" ``` -------------------------------- ### Multiple Locations in a Rule Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Specifies a list of directories to search within a single rule. ```yaml rules: - locations: - ~/Desktop - /usr/bin/ - "%PROGRAMDATA%/test" actions: ... ``` -------------------------------- ### Add a Single macOS Tag Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Applies a single tag to files matching the specified filters. Ensure the 'macos_tags' action is configured correctly. ```yaml rules: - name: "add a single tag" locations: "~/Documents/Invoices" filters: - name: startswith: "Invoice" - extension: pdf actions: - macos_tags: Invoice ``` -------------------------------- ### Filter files by macOS tag (specific color) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Select files that have a specific macOS tag, such as a red tag. ```yaml rules: - name: "Only files with a red macOS tag" locations: "~/Downloads" filters: - macos_tags: "* (red)" actions: - echo: "File with red tag" ``` -------------------------------- ### Filter files by macOS tag (any color) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files based on a specific macOS tag name, regardless of its color. ```yaml rules: - name: "All files tagged 'Invoice' (any color)" locations: "~/Downloads" filters: - macos_tags: "Invoice (*)" actions: - echo: "Invoice found" ``` -------------------------------- ### Python Scripting with Filter Data Access Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Execute Python code that can access data from filters, such as regex capture groups. Ensure filters are defined before this action. ```yaml rules: - name: "You can access filter data" locations: ~/Desktop filters: - regex: '^(?P.*)\.(?P.*)$' actions: - python: | print('Name: %s' % regex["name"]) print('Extension: %s' % regex["extension"]) ``` -------------------------------- ### Filter by 'image' mimetype Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files based on a general MIME type category like 'image'. This allows for broad categorization of files. ```yaml rules: - name: "Filter by 'image' mimetype" locations: "~/Downloads" filters: - mimetype: image actions: - echo: "This file is an image: {mimetype}" ``` -------------------------------- ### Filter and Move PDFs by Creation Year Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filters PDF files and moves them into a directory structure based on their creation year. Requires the 'created' filter to be active. ```yaml rules: - name: Sort pdfs by year of creation locations: "~/Documents" filters: - extension: pdf - created actions: - move: "~/Documents/PDF/{created.year}/" ``` -------------------------------- ### Filter by Date Added Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use the `date_added` filter to access the date a file was added to a folder. It functions similarly to `created` and `lastmodified` filters. ```yaml rules: - name: Show the date the file was added to the folder locations: "~/Desktop" filters: - date_added actions: - echo: "Date added: {date_added.strftime('%Y-%m-%d')}" ``` -------------------------------- ### Move Files Without Renaming Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Moves files matching the specified extensions from the source location to the destination folder without altering their filenames. Existing files in the destination are not overwritten. ```yaml rules: - locations: ~/Desktop filters: - extension: - pdf - jpg actions: - move: "~/Desktop/media/" ``` -------------------------------- ### Make All File Extensions Lowercase Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md This filter processes files to ensure all their extensions are in lowercase. It's useful for standardizing file naming. ```yaml rules: - name: "Make all file extensions lowercase" locations: "~/Desktop" filters: - extension actions: - rename: "{path.stem}.{extension.lower()}" ``` -------------------------------- ### Filter by specific MIME type Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files by an exact MIME type, such as 'application/pdf'. This is useful for targeting specific file formats. ```yaml rules: - name: Filter by specific MIME type locations: "~/Desktop" filters: - mimetype: application/pdf actions: - echo: "Found a PDF file" ``` -------------------------------- ### Delete Old Downloads Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Deletes files in the Downloads directory that were last modified over a year ago and have a .png or .jpg extension. ```yaml rules: - locations: "~/Downloads" filters: - lastmodified: days: 365 - extension: - png - jpg actions: - delete ``` -------------------------------- ### Move Files with Renaming Template and Conflict Resolution Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Moves PDF files to a specified destination, preventing overwrites by renaming new files with an appended index. The 'rename_template' defines the naming convention for renamed files. ```yaml rules: - locations: ~/Desktop/Invoices filters: - extension: - pdf actions: - move: dest: "~/Documents/Invoices/" on_conflict: "rename_new" rename_template: "{name} {counter}{extension}" ``` -------------------------------- ### Python Filter: Reverse Filename Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Use this filter to reverse the base name of a file. It accesses the file's extension and applies string slicing for reversal. ```yaml rules: - name: A file name reverser. locations: ~/ filters: - extension - python: | return {"reversed_name": path.stem[::-1]} actions: - rename: "{python.reversed_name}.{extension}" ``` -------------------------------- ### Detect Duplicate Files Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md The `duplicate` filter identifies duplicate files. It can be configured to detect the original file based on its creation date. ```yaml rules: - name: Show all duplicate files in your desktop and download folder (and their subfolders) locations: - ~/Desktop - ~/Downloads subfolders: true filters: - duplicate actions: - echo: "{path} is a duplicate of {duplicate.original}" ``` ```yaml rules: - name: "Check for duplicated files between Desktop and a Zip file, select original by creation date" locations: - ~/Desktop - zip://~/Desktop/backup.zip filters: - duplicate: detect_original_by: "created" actions: - echo: "Duplicate found!" ``` -------------------------------- ### Python Filter: Access Regex Placeholders for Renaming Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md This advanced filter demonstrates accessing data captured by a previous regex filter. It uses a dictionary lookup to find an email address based on the captured last name and renames the file using this email. ```yaml rules: - name: "Access placeholders in python filter" locations: files filters: - extension: txt - regex: (?P\w+)-(?P\w+)\..* - python: | emails = { "Betts": "dbetts@mail.de", "Cornish": "acornish@google.com", "Bean": "dbean@aol.com", "Frey": "l-frey@frey.org", } if regex.lastname in emails: # get emails from wherever return {"mail": emails[regex.lastname]} actions: - rename: "{python.mail}.txt" ``` -------------------------------- ### Copy Files Without Overwriting Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Copy PDF files to a destination folder, renaming new files if a file with the same name already exists to prevent overwriting. The default counter separator is a space. ```yaml rules: - locations: ~/Desktop/Invoices filters: - extension: - pdf actions: - copy: dest: "~/Documents/Invoices/" on_conflict: "rename_new" rename_template: "{name} {counter}{extension}" ``` -------------------------------- ### Sort Images by Camera Manufacturer Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Sort images by camera manufacturer by combining the 'extension' and 'exif:image.model' filters. This rule moves JPG images into folders named after their camera model, effectively sorting them. ```yaml rules: - name: "camera sort" locations: - path: "~/Pictures" max_depth: null filters: - extension: jpg - exif: image.model actions: - move: "~/Pictures/{exif.image.model}/" ``` -------------------------------- ### Filter files by last modified date (hours, newer) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files modified within a specific recent time frame (e.g., last 5 hours) using the 'newer' mode. ```yaml rules: - locations: "~/Desktop" filters: - lastmodified: hours: 5 mode: newer actions: - echo: "Was modified within the last 5 hours" ``` -------------------------------- ### Filter files by last modified date (days) Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md Filter files based on their last modification date, selecting those modified at least a specified number of days ago. ```yaml rules: - name: "Show all files on your desktop last modified at least 10 days ago" locations: "~/Desktop" filters: - lastmodified: days: 10 actions: - echo: "Was modified at least 10 days ago" ``` -------------------------------- ### Relative Location Definition Source: https://github.com/tfeldmann/organize/blob/main/docs/locations.md Defines a location relative to the current working directory. This is useful for creating portable rules that can be easily copied between projects. ```yaml rules: - locations: "docs" # here "docs" is relative to the current working dir filters: - extension: jpg - size: ">3 MB" actions: - echo: "Warning - huge pic found!" ``` -------------------------------- ### Rename Files: Convert PDF Extensions to Lowercase Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Renames files by converting their '.PDF' extension to lowercase '.pdf'. This action uses filters to target specific file types. ```yaml rules: - name: "Convert all .PDF file extensions to lowercase (.pdf)" locations: "~/Desktop" filters: - name - extension: PDF actions: - rename: "{name}.pdf" ``` -------------------------------- ### Recursively Delete Empty Directories Source: https://github.com/tfeldmann/organize/blob/main/README.md Recursively deletes all empty directories found within the specified locations. This rule targets directories and identifies them by the 'empty' filter. ```yaml rules: - name: "Recursively delete all empty directories" locations: - path: ~/Downloads targets: dirs subfolders: true filters: - empty actions: - delete ``` -------------------------------- ### Delete Empty Subfolders Source: https://github.com/tfeldmann/organize/blob/main/docs/actions.md Deletes all empty subfolders within the specified location. This rule targets directories and filters for empty ones. ```yaml rules: - name: Delete all empty subfolders locations: - path: "~/Downloads" max_depth: null targets: dirs filters: - empty actions: - delete ``` -------------------------------- ### Filter by Date Last Used Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md The `date_lastused` filter allows access to the last usage date of a file. It operates analogously to `created` and `lastmodified` filters. ```yaml rules: - name: Show the date the file was added to the folder locations: "~/Desktop" filters: - date_lastused actions: - echo: "Date last used: {date_lastused.strftime('%Y-%m-%d')}" ``` -------------------------------- ### Python Filter: Odd Student Numbers Source: https://github.com/tfeldmann/organize/blob/main/docs/filters.md This filter selects files where the student number in the filename is odd. It parses the filename, extracts the number, and checks for oddness using the modulo operator. ```yaml rules: - name: "Filter odd student numbers" locations: ~/Students/ filters: - python: | return int(path.stem.split('-')[1]) % 2 == 1 actions: - echo: "Odd student numbers: {path.name}" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.