All templates
Desktop AutomationBeginner
Add Datetime to File Names
Robomotion•Updated 11 months ago

Overview
Renames every file in a directory by appending the current date to its name. A quick way to version artefacts, snapshots, or export batches.
Add Datetime to File Names
Managing locally saved files can be time-consuming for most home and business desktop users. Automate any file-system-related task, such as renaming files, using Robomotion's files and folders nodes.
What Add Datetime to File Names can do
- Build default folder (
Core.Programming.Function) →msg.default_folder = $Home$/templates/.../fixtures. - Input Dialog (
Core.Dialog.InputBox) titledAdd datetime to file names, defaultmsg.default_folder→msg.selected_folder. - Branch on cancel (
Core.Programming.Function,outputs: 2) — empty input short-circuits toCore.Flow.Stop. - List folder (
Core.FileSystem.List,optAbsolutePath: true,optSize: true,optIsDir: true,optCreateTime: true,optTop: 0) →msg.files_to_rename, thenCore.Flow.GoTointoLoop Start. - Iterate (
Core.Programming.ForEach) overmsg.files_to_rename→msg.current_file. - Skip dirs and stamped (
Core.Programming.Function,outputs: 2) — directories and names already matching-YYYYMMDD.are routed toLoop Back Skip; otherwise setsmsg.source_path = current_file.Nameandmsg.create_time = current_file.CreateTime. - Format stamp (
Robomotion.DateTime.Format, custom out layout20060102) frommsg.create_time→msg.stamp. - Build new path (
Core.Programming.Function) — splits on the last/or\\and last.to producemsg.target_path = <dir>\\<stem>-<stamp><ext>. - Check collision (
Core.FileSystem.PathExists) onmsg.target_path→msg.target_exists; if true, a Function routes toLoop Back Skip, otherwiseCore.FileSystem.Move(continueOnError: true) renames source to target andCore.Flow.GoTore-enters the loop. - When the iterator exits, flow reaches
Core.Flow.Stop.
Behind the scenes
Core.FileSystem.ListwithoptCreateTime: trueprovidesCreateTimeper entry, which is what drives the stamp — modification time and wall-clockNoware intentionally not used so the name reflects the file's own origin.- The stamp is placed before the extension (
name-YYYYMMDD.ext), which requires splitting on the last.; files with no extension just getname-YYYYMMDD. - Name collisions are handled silently:
Core.FileSystem.PathExistsplus a branch send already-taken targets to the skip label, so the original file is left untouched with no error. - The
-YYYYMMDD.regex guard prevents repeat runs from re-stamping already-processed files.
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.