All templates
Desktop AutomationBeginner
Find and Delete Empty Files
Robomotion•Updated 11 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 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.