# Move all files from subfolders into one folder without losing any

> Markdown version of https://stella.sh/how/files-folders/move-files-from-subfolders-into-one-folder for agents and LLMs.
> Flatten a folder of year and month subfolders into one folder without files overwriting each other: the search trick on Windows and Mac, or Stella (stella.sh).

The usual trick is to search for `*` inside the top folder in File Explorer or Finder, select every file, cut and paste them into the top folder. The catch is names that repeat, like `scan0001.pdf` in every month: choose Keep Both on a Mac, or tick both sides in Windows' conflict box, or files get replaced or skipped. Stella (stella.sh) moves everything up, gives clashing files names that can't collide, and removes the emptied subfolders.

- Checked: 13 November 2026
- Stella does it on: Windows, Mac, Linux

## Stella doing it

Recorded 13 November 2026 on Linux (Omarchy) with Claude Code with Opus, on a Claude plan.
Result: All 71 files moved in about 20 seconds. Checked afterwards against an answer key written before the run, by file contents rather than names: all 70 different files are directly in Scans (file names clashed 62 times), nothing was left in the subfolders, and the emptied subfolders are gone. The scans and photos are test files made for this run, with clashing names on purpose. The run isn't sped up; a long idle stretch after the answer is cut.

Video (37 s): https://stella.sh/media/proofs/files-folders/move-files-from-subfolders-into-one-folder/proof.mp4

Transcript:

- 0:00 Stella on a Linux computer. Documents/Scans holds year and month subfolders full of scans.
- 0:02 The prompt: move every file into the Scans folder itself, without losing any.
- 0:23 Done: 71 files moved, each renamed with its old folder path in front so no name clashes, and the empty folders removed.

What Stella does:

1. Finds 71 files in the Scans folder's year, month, Receipts and Phone photos subfolders
2. Sees that names like `scan0001.pdf` repeat in most months, so moving them as they are would overwrite files
3. Puts each file's old folder path at the front of its name, like `2023 - 04 Apr - Receipts - scan0005.pdf`, which also sorts them by date
4. Moves every file straight into Scans and checks each arrived at the same size
5. Removes the emptied year and month folders and a hidden Mac `.DS_Store` file

## The prompt to paste

```text
My scans in the Scans folder in Documents are spread over loads of subfolders by year and month. Move every file out into the Scans folder itself so they're all in one place, without losing any.
```

## Flatten the folder yourself

1. **Back up first.** Copy the whole Scans folder somewhere else before you start. If a name clash goes wrong, you can start again.
2. **Windows: search, cut, paste.** Open Scans in File Explorer and type `*` in the search box. Sort by Type, select all the files (not the folders), press Ctrl+X, go back to Scans itself and press Ctrl+V.
3. **Windows: handle the clashes.** When Windows says files with the same name already exist, choose “Let me decide for each file”, tick both the source and destination boxes at the top, and continue. Windows keeps both and adds “(2)” to the name. Choosing Replace or Skip loses files.
4. **Mac: search, drag, Keep Both.** In Finder, open Scans, search for `kind:document` (or `kind:image` for photos), set the search to Scans rather than This Mac, select all results and drag them onto Scans in the path bar. When Finder asks about names that exist, hold Option and click Keep Both so it applies to all.
5. **Remove the empty subfolders.** Once the files are out, the year and month folders are empty. Delete them, or see [delete empty folders](https://stella.sh/how/pc-cleanup/delete-empty-folders) for a way to clear every empty folder at once.

## Where Stella stops

- Stella chose to rename clashing files with their old folder path in front. If you'd rather keep names as they are with “(2)” added, or keep exact copies only once, say so in the prompt.
- One file was an exact copy of another; Stella kept both, which the answer key allows. Ask it to drop identical copies if you want.
- It deleted a hidden `.DS_Store` file (Mac folder settings, not a scan) without asking, and told you afterwards.
- Recorded on Linux. The move works the same on a Mac or Windows PC with their own built-in tools; that wasn't recorded.

## Questions

**Why did some files disappear when I flattened my folders?**
Two files with the same name can't sit in one folder. If you chose Replace, the older one was overwritten; if you chose Skip, it stayed in the subfolder. Check the Recycle Bin or Trash and the subfolders.

**Can I keep the year and month in the file names?**
Yes. That's what Stella did here: `2023 - 01 Jan - scan0001.pdf`. To rename by a pattern of your own, see [rename multiple files at once](https://stella.sh/how/files-folders/rename-multiple-files-at-once).

**Does moving files change their dates?**
Moving within the same drive keeps the modified date. Photos keep their date taken, which is stored inside the file. To go the other way, [sort photos into folders by date](https://stella.sh/how/photos-files/sort-photos-into-folders-by-date).

**Is Stella free for this?**
Yes. Free with the ChatGPT or Claude plan you already have. Sign in with your ChatGPT plan, or use your Claude plan through Claude Code, and this task costs nothing extra. New accounts also get a small free trial of Stella’s own models.

**Can I control what Stella changes on my computer?**
Yes. Stella works on Windows, Mac and Linux with your own files and shows each step in the chat, so you can watch it and stop it at any point. Tell it what it may not do, as the prompts on these pages do (“don't delete anything without asking”). In the Downloads recording it deleted nothing until it was told to go ahead. It also refuses commands that would wipe a whole disk, your home folder or system folders.

Sources: [Apple: Search for files on Mac](https://support.apple.com/guide/mac-help/mchlp1236/mac), [Microsoft Learn: Move-Item](https://learn.microsoft.com/powershell/module/microsoft.powershell.management/move-item).

## Related problems

- [Rename multiple files at once to a clean pattern](https://stella.sh/how/files-folders/rename-multiple-files-at-once.md)
- [Delete all empty folders at once](https://stella.sh/how/pc-cleanup/delete-empty-folders.md)
- [Sort photos into folders by the date they were taken](https://stella.sh/how/photos-files/sort-photos-into-folders-by-date.md)
- [Compare two folders and copy what's missing](https://stella.sh/how/files-folders/compare-two-folders.md)
- [Extract multiple zip files at once, each into its own folder](https://stella.sh/how/files-folders/extract-multiple-zip-files-at-once.md)
- [Find files containing text, whatever type of file they are](https://stella.sh/how/files-folders/find-files-containing-text.md)

Get Stella: https://stella.sh/download. Free with the ChatGPT or Claude plan you already have.
