n1k1c4
n1k1c4

Reputation: 53

How find subfolders in the folder, then move the subfolders to another folder by using batch command

Example:

Folder tree: 

    C:\
    |
    |---lion
    |     |---one
    |     |---two
    |     |---three
    |
    |---bear

I need move subfolders (one, two, three, etc.) in the folder "bear".

I know how to find and move specific file types, but how to find and move the folders don't know:

for /R "c:\one" %%f in (*.jpg) do move /Y "%%f" "c:\two"

Upvotes: 0

Views: 99

Answers (2)

foxidrive
foxidrive

Reputation: 41297

This should work too.

@echo off
pushd "c:\lion"
for /d %%a in (*) do move "%%a" "c:\bear"
popd

Upvotes: 0

Endoro
Endoro

Reputation: 37589

Try this (fixed):

for /d /r "C:\lion" %%a in (*) do md "C:\bear\%%~nxa" &robocopy /e /move "%%~fa" "C:\bear\%%~nxa"

Upvotes: 1

Related Questions