Jump to content

Move Folders


L3arn3r
 Share

Recommended Posts

Moves files and renames files and directories.

To move one or more files:

MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:

MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

[drive:][path]filename1 Specifies the location and name of the file

or files you want to move.

destination Specifies the new location of the file. Destination

can consist of a drive letter and colon, a

directory name, or a combination. If you are moving

only one file, you can also include a filename if

you want to rename the file when you move it.

[drive:][path]dirname1 Specifies the directory you want to rename.

dirname2 Specifies the new name of the directory.

/Y Suppresses prompting to confirm you want to

overwrite an existing destination file.

/-Y Causes prompting to confirm you want to overwrite

an existing destination file.

The switch /Y may be present in the COPYCMD environment variable.

This may be overridden with /-Y on the command line. Default is

to prompt on overwrites unless MOVE command is being executed from

within a batch script.

Thats the help file for the 'move' command in windows.

Edited by digip
Link to comment
Share on other sites

Explain Please?

Where i can put my directory names?

Senario: Dir1 is in "D" Drive and in "Dir1" there are more than 100 folders with extra folder called "Dir99" now i want to move all folders into Dir99?

Based on your description it sounds like you have something like this:

D:\

D:\Dir1\

D:\Dir1\Dir00\

D:\Dir1\Dir01\

D:\Dir1\Dir02\

...

D:\Dir1\Dir98\

D:\Dir1\Dir99\

And it sounds like you want to achieve something like this:

D:\

D:\Dir1\

D:\Dir1\Dir99\

D:\Dir1\Dir99\Dir00\

D:\Dir1\Dir99\Dir01\

...

D:\Dir1\Dir99\Dir98\

It doesn't make a lot of sense to me why you would want to do that, but that's the best that I can understand your description of the problem.

The batch script I gave you as an example will allow you to do this:

D:\Dir1> mv.bat Dir00 Dir01 Dir02 ... Dir97 Dir98 Dir99

That will move Dir00 through Dir98 into Dir99. Specifically, it will move each path specified as an argument into the path specified as the last argument. However, it still requires that you manually type the name of each directory which you want to move into the target directory.

If the names of the directories you want to move are numerically incremented (as in this example) then you can use a FOR loop to move each one individually.

D:\Dir1> FOR /L %i in (0, 1, 98) do move Dir%i Dir99

Of course, that loses the zero-padding which I earlier specified in the example. So here is how you would do it with zero-padding.

D:\Dir1> FOR /L %i in (0, 1, 98) do (

> set "num=0%i"

> set "num=%num:~-2%"

> move Dir%num% Dir99

> )

TL;DR: Stop trying to do anything sophisticated with CMD and install a Borne-compatible shell (like BASH) on that system. Either MSYS or Cygwin would be good options. MSYS is included when you install MinGW or Git. As a last resort, I suppose you could install PowerShell and learn how to use it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...