Vibe Coding a Script to Clean Up Files

Rules first, dry run second, real folders last

Voiskey Voiskey Team
Voice Vibe CodingAI Code PromptsVibe Coding Script

Define the Folder Rules First

Vibe Coding a Script to clean up files starts with rules, not with code. Open a note and list the folders involved, what each folder is for, and how long a file should stay there. Name the file kinds you will touch and the kinds you will never touch, such as archives, source material, or anything with a collaborator's name on it. Say where a file goes when you are unsure. These rules become the script's contract, and every later prompt should point back to them. Without the rules, a cleanup script becomes a fast way to lose something important.

Walk the folder tree with a real example. Pick one file of each kind and trace its journey from arrival to archive or removal. Write down the decision at each step: who moved it, when, and where it went. If a file has no clear destination, that is a rule you have not written yet. Speak the journey as a short sequence and check that a colleague can follow it. The example turns an abstract policy into a test you can run after the script exists. One traced file is worth a page of policy language. Keep the example path in the note beside the rules.

Decide the time rules in plain units. Say how old a file must be before it moves, how long it stays in the archive, and what the reference date is: the file's modified time, its created time, or the date in its name. State the time zone if names include dates. Ambiguity here causes the worst cleanup mistakes, because two people read old differently. Write the rule as a sentence with a number and a unit, then ask a colleague to apply it to three files by hand before you write any code. A rule that survives three hand applications is ready for a script.

Add the safety rules before the cleanup rules. Never remove a file unless it has been moved to the archive and verified there. Never touch a file that is open or locked. Never follow links out of the chosen folders. Stop and report when a count is unexpectedly large. Write these as a numbered list and read them aloud at the start of the build. Safety rules are not bureaucracy; they are the reason a small mistake stays small, and they belong in every prompt you dictate. Read the list again before the first real run. A script that stops early is easier to trust than one that never does.

Speak the Script Contract, Then a Dry Run

Write the script contract as inputs, outputs, and limits. Inputs are the root folders and the rules. Outputs are the moved, archived, and untouched groups, plus a report. Limits are the safety rules from the previous step and the maximum number of files per run. Speak the contract as five or six sentences and ask a colleague to repeat it back. If they add a step you did not say, the contract has a gap. A dry run is the first output, not the last, because it lets you compare intent with reality before anything moves. Put the contract at the top of the script as a comment.

Describe the dry run in observable terms. It reads the folders, applies the rules, and prints what it would move, what it would skip, and why. It changes nothing. Ask for a summary count by rule, so a rule that matches far more files than expected stands out. Speak the dry run as its own deliverable and review it before asking for the real run. A dry run that is easy to read is the main safety feature of the whole script. Ask for one line per file, not a paragraph per folder. Counts by rule reveal a bad rule faster than a list of names.

Decide the report format now. A simple table with the file path, the rule applied, the action, and the reason is enough. Add a final summary line with totals. Say the format in the prompt so every run produces something you can compare with the last one. If the script must send the report somewhere, describe that step and test it with a small folder first. A report that changes shape each run is hard to review, and a hard-to-review report defeats the purpose of running a cleanup on a schedule. Keep the columns fixed and the reasons short. Then a monthly run can show a trend at a glance.

Set the conversation rules for the build. Ask for one function at a time, with its inputs and outputs named. Ask for the dry run path before the move path. Ask for a test folder with sample files that covers each rule and each safety condition. When a prompt returns more than one function, ask for the smaller piece. These rules keep the session reviewable, and they match the way you will test: one rule, one case, one result. Write them at the top of the task so they survive a long session. Small pieces are also easier to dictate and easier to correct. Correct the piece before the next one starts.

Dictate the Script in Small Blocks

Build the walker first. Ask for a function that lists files under each root, with a filter for the kinds you named, and no changes. Speak the roots and the extensions as explicit values. Then run it on a test folder and compare the list with what you see. A walker that finds the wrong files makes every later step wrong, so this is the one place to slow down. Keep the walker's output in the report format you decided earlier. A correct list is the foundation for every rule that follows. Test it on a folder with an unusual name and a nested folder.

Add one rule at a time, each as a decision function. A rule takes a file and the reference date and returns move, archive, skip, or stop. Speak the rule as a sentence with a condition and an outcome, then ask for the function and its tests. Run the dry run after each rule, not after all of them. When a rule fires on a file it should skip, fix the rule before adding the next. One rule per prompt keeps the cause of a wrong result obvious, and it keeps the spoken request short. A rule with a test is a rule you can change later. Keep the rule order fixed so results stay comparable.

Build the move and archive steps only after the dry run is trustworthy. Ask for a function that moves a file to its destination and refuses to overwrite an existing name. Ask for a check that the file exists at the destination before the source is removed. Speak these as separate prompts and test each on a copy. The move is the riskiest step, so it deserves the smallest changes and the most checks. A script that can describe a move before it performs one is a script you can run on real folders. Never combine the move and the removal in one prompt. Separate steps are easier to stop and easier to explain.

Finish with a summary function. It reads the report and prints counts by rule, by action, and by folder. Ask for a warning line when a count passes the limit you set. Speak the summary as the last block and run it against the dry run and the real run to compare. If the counts differ in a way the rules do not explain, stop and investigate before the next run. A summary is how a weekly cleanup stays a five-minute check instead of a full review. The summary is also the first thing to read after an unexpected result. Keep it at the end of the output so it is easy to find.

Test on a Copy Before the Real Run

Create a test tree that mirrors the real one, with small files and the same folder names. Include one file for each rule, one nested folder, one file with a space in the name, and one file that must never be touched. Run the dry run and compare the report with the expected list you wrote by hand. Fix the rule or the test, not the expectation, unless the expectation was wrong. A test tree with a deliberate tricky case catches more problems than a large run on real folders, because you can see exactly what should happen. Keep the test tree in the repository so it runs again next month.

Test the safety stops on purpose. Lock a file, open one in another app, put a link inside a root, and create a run that exceeds the limit. The script should stop and report, not continue quietly. Check that the archive copy exists before the source is removed, and that a name collision is refused. Write each result in the test note. Download Voiskey if you want to dictate these results at the insertion point while the test is running, so the note matches the case you just ran. Repeat the stops after every rule change and note the date.

Run the real folders in two passes. The first pass is a dry run with the exact roots and rules; compare the counts with the test run and with your hand count. Investigate any difference before the second pass. The second pass performs the moves, with the limit set low so it stops early. Review the report, raise the limit, and run again. This staged approach turns a risky operation into a series of small, checkable steps, and it gives you a stopping point at every stage. Keep the dry run report beside the real run report for comparison. A difference between them is the most useful signal you have.

Record what you learned in the rule note. Add the cases that failed, the rules that changed, and the tests that now cover them. If a case was too dangerous to run for real, say so and describe the substitute test. Review the note with the colleague who will run the cleanup next time, and ask them to run the dry run once while you watch. Sign off only when they can explain the report without your help. A cleanup script is ready when someone else can run it safely. That is also the moment to put it on a schedule. Schedule only after the handover, never before.

Document and Schedule the Cleanup

Write a one-page runbook for the cleanup. It states the roots, the rules, the dry run command, the real run command, the limit, and the report location. Add the name of the owner and one backup. Read it aloud and fix any step that takes more than one breath. Store it next to the script and link it from the folder that the team checks. A runbook that is hard to read becomes a script nobody runs, and a cleanup that stops running is how folders fill up again. The runbook is part of the script, not an optional extra. Update both in the same change.

Schedule the run for a quiet time and a fixed rhythm. A weekly dry run and a monthly real run is a common pattern for a small team. Record the schedule in the runbook and in the team calendar, with the owner named. The run should stop early if a count is unusual, so the owner sees a report before anything large happens. Speak the schedule decision in the runbook note so a new owner understands why the rhythm exists. A schedule that nobody owns is a reminder that everyone ignores. Put the owner's name next to every scheduled run. Rotate the backup so the knowledge does not live in one person.

Keep the script and the runbook current with short spoken updates. When a folder changes or a rule is added, press the shortcut in the runbook, say the change, and edit the line at the insertion point. Download Voiskey for the owner so the update takes seconds instead of a separate writing session. The workflow is Speak-Polish-Type-Edit, and it suits this maintenance because the changes are small and specific. A current runbook is the difference between a tool the team trusts and a script that only one person dares to run. Keep the last three updates in a short log.

Review the cleanup quarterly. Open the runbook, the reports, and the test results. Ask whether the rules still match how the team works, whether the archive is still needed, and whether any skipped files deserve a rule. Retire rules that no longer fire, and add tests for new cases. Note the decision and the date. Download Voiskey and dictate the review notes into the runbook, then edit them at the insertion point. A quarterly review keeps a small script aligned with a changing team, and alignment is what makes the next cleanup uneventful. Invite the backup owner to the review.

FAQ s

Voiskey is an AI voice typing app for desktop use. You press a shortcut, speak the rule, the roots, and the file kinds, and text appears at the insertion point in your editor. It removes filler words and false starts, and adapts formatting, so a spoken folder rule becomes a precise prompt for the script.

Yes. Voiskey turns spoken requests into AI-ready prompts, including file names, paths, and commands. Say the root folder and the extensions exactly, then review the text at the insertion point. If a path is long, say it once slowly, and Voiskey learns names, jargon, acronyms, and spelling preferences for the next request.

Say the folder, the file kind, the age rule with a number and a unit, and the action: move, archive, skip, or stop. Keep the safety rule separate. Voiskey adapts punctuation and formatting to the task, so the spoken sequence arrives as a clear rule. Review it at the insertion point before adding the next rule.

Voiskey supports 100+ languages and translation. You can dictate the runbook in one language and ask for another version, then review the result at the insertion point. Keep folder names, commands, and file extensions unchanged, and check that the translated steps still name the dry run before the real run.

Say less. Get more
Say less. Get more
Say less. Get more
Say less. Get more
VoiskeyVoiskey

Your voice, amplified.

Download Voiskey for Mac and Windows and speak each cleanup rule at your cursor.

Use it across macOS, Windows, iOS, and Android

Use it across