All templates
Desktop AutomationIntermediate
Delete Files of Specific Size Range
Robomotion•Updated 9 months ago

Overview
Scans a directory and deletes files whose size falls inside a min/max range. Useful for pruning oversized logs or clearing tiny scratch files.
Delete Files of Specific Size Range
Managing considerable amounts of files can be inefficient when performed by manual labor. Robomotion enables you to filter and handle files and manage your machine's storage automatically.
What Delete Files of Specific Size Range can do
- Seed fixtures (
Core.Programming.Function+ threeCore.FileSystem.WriteFile) — dropssmall.txt(200 B),medium.txt(3 KB) andlarge.txt(20 KB) undermsg.fixtures_dirso the template is runnable out of the box. - Input Dialog (
Core.Dialog.InputBox) titledDelete files by size range, promptWhat is the minimum size of the files you want to delete? (in KB), default1→msg.min_size_text. - Input Dialog (
Core.Dialog.InputBox) with promptWhat is the maximum size of the files you want to delete? (in KB), default10→msg.max_size_text. - Input Dialog (
Core.Dialog.InputBox) with promptPlease select the folder to delete files from...., defaultmsg.fixtures_dir→msg.selected_folder. - Parse inputs (
Core.Programming.Function,outputs: 2) — coerces tomsg.minimum_size/msg.maximum_size; missing folder or NaN short-circuits toCore.Flow.Stop. - List directory (
Core.FileSystem.List,optAbsolutePath: true,optSize: true,optIsDir: true) onmsg.selected_folder→msg.all_files_in_folder. - Loop (
Core.Flow.Label+Core.Programming.ForEachovermsg.all_files_in_folder→msg.current_file):- Size range check (
Core.Programming.Function,outputs: 2) — skips directories; keeps entries whereSize / 1024is within[minimum_size, maximum_size]. - In-range files: set
msg.file_to_delete = msg.current_file.Name, thenCore.FileSystem.Delete(continueOnError: true), thenCore.Flow.GoTothe loop label. - Out-of-range files:
Core.Flow.GoTothe loop label directly.
- Size range check (
- When the ForEach exhausts the list it falls through to
Core.Flow.Stop.
Behind the scenes
- Size comparisons convert bytes to KB (
Size / 1024) and are inclusive on both bounds — a 1024 B file withminimum_size = 1passes. - Directory entries are filtered out before the size check so nested folders aren't considered for deletion.
- Deletion is unconditional (no recycle bin, no confirmation) and uses
continueOnErrorso one locked file doesn't abort the loop.
More desktop automation templates
See all 11 →- Add Datetime to File NamesRenames every file in a directory by appending the current date to its name. A quick way to version artefacts, snapshots, or export batches.
- Copy FilesCopies every file from a source directory into a destination, with optional overwrite. Demonstrates how to enumerate files and drive file-system operations from a subflow.
- Find and Delete Empty FilesWalks a directory, locates zero-byte files, and deletes them in a single pass. Handy for cleaning up broken export folders.
- GUI Testing CalculatorDrives the Windows Calculator through native UI automation to validate arithmetic. A concrete template for end-to-end GUI testing of desktop apps.
- Open a FolderLaunches the system file explorer pointed at a given path. Minimal template demonstrating the Application.Launch node.
- Print Current Week's CalendarGenerates an HTML page for the current week and sends it to the default printer. Useful for team dashboards or physical planning boards.