All templates
Desktop AutomationBeginner
Find and Delete Empty Files
Robomotion•Updated 9 months ago

Overview
Walks a directory, locates zero-byte files, and deletes them in a single pass. Handy for cleaning up broken export folders.
Find and Delete Empty Files
Managing large amounts of files is a time-consuming task, and it can be considered one of the best candidates for automation. Robomotion allows you to fully automate file-related tasks, such as deleting empty files from your desktop.
What Find and Delete Empty Files can do
Core.Flow.SubFlowdownloads fixtures; a Function buildsmsg.fixtures_dir,msg.empty_one_pathandmsg.empty_two_path.- Two
Core.FileSystem.Createnodes (optType: 'file',continueOnError: true) seedempty_one.txtandempty_two.txtso the demo has something to find. - Input Dialog titled
Delete empty files, messagePlease select the folder to delete files from...., defaultmsg.fixtures_dir→msg.selected_folder. - Branch (
Core.Programming.Function,outputs: 2) — proceed whenmsg.selected_folderis non-empty; otherwiseCore.Flow.Stop. Core.FileSystem.ListwithoptAbsolutePath: true,optSize: true,optIsDir: true,optTop: 0→msg.all_files_in_folder.Core.Flow.Label+Core.Programming.ForEachovermsg.all_files_in_folder→msg.current_file; a zero-size check (outputs: 2) routesIsDir: false && Size === 0to the delete branch and everything else to a skip branch.- Delete branch: Function assigns
msg.file_to_delete = msg.current_file.Name,Core.FileSystem.Delete(continueOnError: true), thenCore.Flow.GoToback to the loop label; the ForEach exit edge goes toCore.Flow.Stop.
Behind the scenes
- The listing is non-recursive — only the selected folder itself is inspected, so nested folders are left untouched.
optAbsolutePath: truecombined with the Function copyingcurrent_file.Namegives the delete node a fully qualified path; relative paths would resolve against the robot's working directory and delete the wrong files.optSize: trueon the List node pre-populates the size field so the loop does not need a per-fileStatround-trip.- Deletion is immediate — there is no confirmation dialog or audit log; wire a logger or a dry-run guard if the flow is used against real user data.
continueOnError: trueon both the seed creates and the delete makes the flow tolerant of pre-existing or locked files, so a single stubborn entry does not abort the whole cleanup.
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.
- Delete Files of Specific Size RangeScans a directory and deletes files whose size falls inside a min/max range. Useful for pruning oversized logs or clearing tiny scratch files.
- 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.