1

I have got a series of folders in a directory:

C:\directory\folderx
C:\directory\foldery
C:\directory\folderz
etc.

Those folders amount to approximately one thousand in total, whereby I aim to move about half of them.

I want to move those folders with contents into another folder in the same directory (used a file listing.bat to parse the folder titles and sort them, therefore I have obtained the final list of folders of interest in .txt format).

C:\directory\folderq

So that the result will look like this:

C:\directory\folderq\folderx
C:\directory\folderq\foldery
C:\directory\folderq\folderz
etc.

I'm not sure whether the following batch command would work for moving multiple folders, I'm actually afraid it will only result in folderx falsely being moved in to foldery and abort the command:

move C:\directory\folderx C:\directory\foldery C:\directory\folderz > C:\directory\folderq
aschipfl
  • 33,626
  • 12
  • 54
  • 99
kvari
  • 25
  • 1
  • 7

3 Answers3

1

To move all folders within C:\directory into C:\directory\folderq, you could use the following:

for /D %%D in ("C:\directory\*.*") do (
    if /I not "%%~nxD"=="folderq" (
        move "%%~D" "C:\directory\folderq"
    )
)

The if query prevents folderq to be attempted to be moved into itself.


If you have a list of folders you want to move in a text file C:\directory\list.txt like this...:

C:\directory\folderx
C:\directory\foldery
C:\directory\folderz

..., you could use this code:

for /F "usebackq delims=" %%D in ("C:\directory\list.txt") do (
    move "%%~D" "C:\directory\folderq"
)
aschipfl
  • 33,626
  • 12
  • 54
  • 99
0

The command does not work this way, you could specify a directory to move or files but not multiple directories. So you could call the command for each directory once:

move C:\directory\folderx C:\directory\folderq
move C:\directory\foldery C:\directory\folderq

Or using a very simple script (moveDirs.bat) for moving multiple directories:

ECHO OFF
for /D %%x in (%*) do move "%%~x" "C:\directory\folderq"

you could call this script with: moveDirs.bat C:\directory\folderx C:\directory\foldery

wake-0
  • 3,918
  • 5
  • 28
  • 45
  • i'll be trying the first choice as it seems more suited for moving specified part of the folders in the directory and not all, although it seems to be tedious a trifle. I consider accelerating the process by working on a data sheet so as to pen down those dull coding lines. – kvari Nov 12 '16 at 08:31
-1

Assuming you are using Windows, its easiest to just drag and drop the directories into the new folder. If its in the same file explorer window, it moves by default. If not, clicking the SHIFT key while dragging moves instead of copies.

TDWebDev
  • 86
  • 5