- Before this lesson
- Files and folders
- You will learn to
- Combine List Files, a loop, Regex and File Operation
- Run safely on test files
- Sample files
- practice-folder-setup.station.json · tidy-inbox.station.json
Scenario. Your Downloads or inbox folder fills up with mixed files. You want them sorted into folders by type.
Supported: Windows and macOS (on Windows, set the folder variable first). Station version: see the note at the end of the page.
Input and output
- Input:
{{folder}}/inboxwith four test files, created bypractice-folder-setup.station.json. - Output:
{{folder}}/sorted/txt,sorted/csvandsorted/jsonwith the files moved into them.
Steps
- Import and run Practice folder setup.
- Import Tidy the inbox by file type (
tidy-inbox.station.json) and read it in Advanced:- Files in the inbox: List Files →
files. - For each file: Loop over
filesasfile. - Find the extension and Find the file name: Regex match with
[^.\\/]+$and[^\\/]+$. - Make the type folder: File Operation create_folder
{{folder}}/sorted/{{ext}}. - Move the file: move to
{{folder}}/sorted/{{ext}}/{{fileName}}.
- Files in the inbox: List Files →
- Run it.
How it works
The loop handles any number of files. The regular expressions take everything after the last dot (extension) and after the last slash (name), on Windows and Mac paths alike.
Troubleshooting
- Could not find or nothing moved: check the
foldervariable and that setup ran. - A file without an extension ends up in a folder named after its whole name. Add an If Condition to skip such files.
Optional improvements
- Use copy instead of move until you trust it.
- Skip files newer than today with the DateTime activities.
- Point it at a copy of a real folder, never at the original first.
Activities in this lesson
List Files · Loop · Regex · File Operation · Math · Log
Saved only in this browser.
Workflow engine-tested. The sample workflow was executed with the macOS Station engine (StationCore) without the user interface. UI steps are source-verified. Written against RPAi Station for macOS 0.1.0 (1) (RPAi_Station_2.0 @ port/macos 9864e96) and the Windows source (RPAi_Station_2.0 @ codex/native-station e68f16d). Reviewed 2026-11-30. UI labels may differ slightly in other versions; see versions and changes.