You state that the following code creates a file named "Archive" in the archive folder:

for file in copyPath.rglob("*V1.2*"):
    shutil.move(file,Path(file.parent,"Archive"))

shutil.move only moves your files into a directory if the directory already exists. Otherwise, it'll move (rename) your file. I guess that Path(file.parent, "Archive") is not a directory, so every file matching the condition is moved into a file called "Archive", each file overwriting the previous one.

The fix should be simple:

for file in copyPath.rglob("*V1.2*"):
    target = Path(file.parent, "Archive")
    if target.is_file():
        raise ValueError(f"Invalid directory: {target} is a file!")  # safety check to avoid overwriting files and data loss

    if not target.is_dir():
        target.mkdir(parents=True)  # <- this should solve your problem

    shutil.move(file, target)
Answer from Green 绿色 on Stack Overflow
Discussions

glob and rglob can be slow for large directories or lots of files
Hello! While gleefully using cloudpathlib, I needed a recursive iteration of files in a directory. This directory is large (6238 files), so my first approach - a recursive iterdir() + is_file() - t... More on github.com
🌐 github.com
October 7, 2022
glob.glob vs Path.glob
glob.glob returns meager ol' strings whereas Path.glob returns you easy to work with path objects. More on reddit.com
🌐 r/learnpython
7
3
January 8, 2023
Why you should be using pathlib
Trey, this is a great article. I'm a huge fan of pathlib. More on reddit.com
🌐 r/Python
33
41
December 20, 2018
Which is much more efficient, glob.glob() or os.listdir()?

There's going to be almost no difference. Under the covers, glob is essentially doing the same thing as your listdir code (ie calling listdir and then checking if the paths match a particular pattern). In fact, it's actually doing a bit more work since it's more general (ie. handles more types of patterns than just "end of file"), so it's actually going to be the slower one.

However the difference is going to be pretty much undetectable unless you're looking at directories with millions of files (and even then is going to be pretty negligible). Computers are fast, and this kind of check is going to take a tiny amount of time - the time to actually access the disk is always going to completely dwarf it - trying to optimise it is like trying to reduce the time it takes a train door to open in an effort to cut down the time a 10 minute journey takes. Sure: maybe you could cut half a second off the time with a faster door, but it's not going to be noticable next to the travel time.

however I need to specify a chdir() before it starts

Not at all - you can include the path as part of your pattern. Ie glob.glob("path/to/file/*.pdf")

More on reddit.com
🌐 r/learnpython
10
5
November 22, 2016
🌐
Real Python
realpython.com › lessons › listing-conditionally-rglob
Listing Conditionally Using .rglob() (Video) – Real Python
In this example, you can see the same items as before are listed, such as realpython, rename_files.py, and request.py. This shows that the call to glob method with pattern two asterisks, forward slash R and a single asterisk is equivalent to the .rglob() method with the R and single asterisk.
Published: June 11, 2024
🌐
Computer Science Atlas
csatlas.com › python-list-directory
Python 3: List the Contents of a Directory, Including Recursively — Computer Science Atlas
March 27, 2021 - Since rglob is the same as calling glob with **/, we could also just use glob to achieve the same result: from pathlib import Path for p in Path( '.' ).glob( '**/*.html' ): print( p ) On any version of Python 3, we can use the built-in os library to list directory contents.
🌐
Switowski
switowski.com › blog › pathlib
Pathlib for Path Manipulations - Sebastian Witowski
July 17, 2023 - def os_walk_files(): python_files = [] for root, dirs, files in os.walk("."): for filename in files: if filename.endswith(".py"): python_files.append(root + filename) return python_files · But it's much easier to use the glob module instead. That way we just need one line of code: import glob def glob_find_files(): glob.glob("./**/*.py", recursive=True) pathlib comes with a similar function called rglob().
🌐
Python
docs.python.org › 3 › library › pathlib.html
pathlib — Object-oriented filesystem paths — Python 3.15.2 documentation
In Path.glob() and rglob(), a trailing slash may be added to the pattern to match only directories.
🌐
Real Python
realpython.com › get-all-files-in-directory-python
How to Get a List of All Files in a Directory With Python – Real Python
January 12, 2025 - For a direct list of files and folders, you use .iterdir(). The .glob() and .rglob() methods support glob patterns for filtering files with specific extensions or names. For advanced filtering, you can combine these methods with comprehensions or filter functions. By the end of this tutorial, you’ll understand that you can: List all files of a directory in Python using pathlib.Path().iterdir()
Find elsewhere
🌐
PyTutorial
pytutorial.com › python-pathlib-rglob-explained
PyTutorial | Python Pathlib rglob() Explained
March 19, 2025 - One of its most useful methods is rglob(). This method allows you to recursively search for files and directories. It is similar to glob(), but it searches through all subdirectories.
🌐
Rednafi
rednafi.com › home › python › no really, python's pathlib is great
No really, Python's pathlib is great | Redowan's Reflections
June 30, 2026 - By default, both Path.glob and Path.rglob returns a generator object. Calling list on them gives you the desired result. Notice how rglob method can discover the desired files without you having to mention the directory structure with wildcards explicitly.
🌐
GitHub
github.com › drivendataorg › cloudpathlib › issues › 274
glob and rglob can be slow for large directories or lots of files · Issue #274 · drivendataorg/cloudpathlib · GitHub
October 7, 2022 - In my mind, shortcutting these common "list everything" recursive calls to glob and rglob to a much faster version with _list_dir may be the best path forward. No new API, direct speedups, relatively simple implementation. The downside is the runtime different between a glob with more complex logic and a simple recursive one may be substantial (which could be confusing).
🌐
DEV Community
dev.to › guionardo › fast-folder-iteration-in-python-3g1f
Fast folder iteration in python - DEV Community
January 21, 2022 - import pathlib folder='some_folder/another_folder' for path in pathlib.Path(folder).rglob('*'): if path.is_file(): yield str(path) ... Creating sample files + Creating folder ./test_files + Creating files LEVELS=6 FOLDER_COUNT=6 FILE_COUNT_BY_FOLDER=20 + Created 933120 files in 0:02:08.928680 * Running iterators: GlobFolderIterator IGlobFolderIterator OSWalkFolderIterator ScanDirIterator PathLibFolderIterator
🌐
GitHub
facelessuser.github.io › wcmatch › pathlib
wcmatch.pathlib - Wildcard Match Documentation
match mimics Python's pathlib version of match. Python's match uses a right to left evaluation that behaves like rglob but as a matcher instead of a globbing function. Wildcard Match emulates this behavior as well. What this means is that when provided with a path some/path/name, the patterns ...
🌐
GitHub
gist.github.com › devlights › 7f2f4c7a46e835ba3c6ceb7f8f78f91f
[Python] pathlib の glob と rglob のサンプル · GitHub
[Python] pathlib の glob と rglob のサンプル. GitHub Gist: instantly share code, notes, and snippets.
🌐
PyPI
pypi.org › project › rglob
rglob · PyPI
Lightweight recursive search for ... — globs, content grep, stat/dup helpers, JSON-stable outputs, typed agent API, optional MCP server. ... ____ ____ _ _ | _ \ / ___| | | ___ | |__ | |_) | | _ | |/ _ \| '_ \ | _ <| |_| | | | (_) | |_) | |_| \_\\____| |_|\___/|_.__/ / / / / / Lightweight recursive search for Python, CLIs, and coding agents. Modern Python has pathlib.Path.rglob, and external ...
🌐
Chris-piekarski
chris-piekarski.github.io › python-rglob
rglob
Lightweight recursive glob helpers for Python — find files, count lines, sum sizes. This is a small labor-of-love package. Modern Python has pathlib.Path.rglob and tools like fd/ripgrep exist; rglob is small, easy to read, and ships with friendly helpers for the two things you usually want next: count lines and sum sizes.
🌐
Roadmap
roadmap.sh › python › glob
Python glob Module: File Pattern Matching Explained
March 3, 2026 - Both Path.glob() and Path.rglob() return Path objects rather than strings. This gives you cleaner path handling, simpler joins, and better readability when chaining file operations.
🌐
GeeksforGeeks
geeksforgeeks.org › python › pathlib-module-in-python
Pathlib Module in Python - GeeksforGeeks
\ProgramFiles\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\abc.py \ProgramFiles\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\aifc.py \ProgramFiles\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\antigravity.py \ProgramFiles\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2288.0_x64__qbz5n2kfra8p0\Lib\argparse.py · Explanation: Here, unlike iterdir() which lists only immediate contents, rglob(*.py) recursively finds all .py files under the directory tree.
Published: June 15, 2026
🌐
DataCamp
datacamp.com › home › tutorials › python › a comprehensive guide to using pathlib in python for file system manipulation
How to Use Python's Pathlib (with Examples) | DataCamp
May 22, 2024 - The reason is that .glob() only searches inside the given directory, not its subdirectories. We can solve this by doing a recursive search, for which we need to use the rglob() method, which has similar syntax: