How can I MOVE, not copy all the files with the same extension from hundreds of sub directories into a single folder without overwriting same name files?

  • 2
    Welcome to superuser. Please tell us what you have tried so far.
    – CharlieRB
    Jun 20, 2013 at 11:41

3 Answers 3


In DOS do:

FOR /R "C:\MoveFromDirectory" "%i" IN (*.mp3) DO MOVE "%i" "C:\Move2Directory"

Change the "MoveFromDirectory" to the directory you are searching in. Change the *.mp3 to whatever file extension you need to. Change Move2Directory do the location of where you are wanting to move them to.

  • I don't see how same-name files won't be overwritten, can you explain?
    – MDMoore313
    Jun 20, 2013 at 17:27
  • The MOVE command by default will not overwrite files without prompting when ran from a command line. If you are using this in a Batch file you will need to add /-Y after the DO MOVE. It will prompt you if you want to overwrite.
    – Travis
    Jun 20, 2013 at 17:31

Fairly easy with Powershell. This script grabs all the files with the .txt extension (from the current directory) and operates on each one: If the destination filename exists it appends the current timestamp (to the millisecond) to the destination filename.

$DestPath = "C:\NewFolder"

Get-ChildItem .\*.txt -recurse | foreach{

    if(Test-Path "$DestPath\$($_.Name)" -eq true)
        Copy-Item $_ -Destination "$DestPath\$($_.BaseName)-$($(get-date).ToString("yyyyMMddhhmmssss"))$($_.Extension)"

        Copy-Item $_ -Destination $DestPath
  • Also, if you really want to move, use the move-item cmdlet instead of copy-item.
    – MDMoore313
    Jun 20, 2013 at 17:26

Search all file's with a given extension, by entering something like *.exe in the upper right corner search bar of a windows explorer window. That will search for all .exe files in the current directory as well as sub-directories. At this point, all of those files will be listed in the window. You can now select them, and use cut/paste, rename them, or any other action you could perform normally in windows explorer.

  • But you can edit your question, which is preferable over an answer.
    – Patrick B.
    Jun 20, 2013 at 11:53
  • 4
    This isn't his question Patrick.
    – Travis
    Jun 20, 2013 at 11:54
  • 1
    This is, in fact, the simplest method; if you only need to do it once.
    – zeel
    Jun 20, 2013 at 18:28
  • 1
    This I believe only work in Win7+.
    – Travis
    Jun 21, 2013 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .