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