All templates
Desktop AutomationIntermediate
Delete Files of Specific Size Range
Robomotion•Updated 11 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 17 →- Every customer from a CSVThe Windows Recorder's customer task run for every row of a CSV file, each typed value replaced by the row's field, with a Catch that logs a row the app will not take and goes on with the next.
- Putting it togetherOne flow over three systems. Headless Chrome reads today's web orders from Acme ERP Web, the finance system is asked about each customer over Remote Desktop, and the orders with nothing overdue are entered into Acme ERP for Windows, line by line, with a report at the end.
- Reading from a Java applicationA flow that signs in to Acme ERP (Java Edition), reads a customer's credit limit and the fasteners in the product table, works out how many boxes of each the limit covers, and writes the answer to a CSV file.
- Reading over Remote DesktopA flow that logs on to Acme ERP over Remote Desktop, reads the outstanding and overdue totals off the Invoices screen with OCR, each anchored to its label, and writes the overdue share to a CSV file.
- Slow sessionsA flow recorded on a good Remote Desktop session that logs on and updates a customer's email, phone and notes in Acme ERP, and still gets every value right on a slow session that loses keystrokes.
- Windows dialogs and gridsA flow that signs in to Acme ERP for Windows, waits for its orders grid, reads it with Get Table Data, exports the orders on hold through the Save As dialog, and closes the app answering its "Save changes?" question.