• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8344
  • Last Modified:

command line : move folder and subfolders

hi,
is there a command line to move a folder and all subfolders & files  to an other folder on the same drive ?

not copy then delete but really move (not robocopy / move ),

because gigas of data, and about 300 folders to deal with...


thanks
0
ingetic
Asked:
ingetic
  • 2
1 Solution
 
MessHallManCommented:
The DOS command move should work.

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.
0
 
ingeticAuthor Commented:
oOps...

i hadn't write the right question,

I need to move all the subfolders & files of the main folder to another folder, but not the main folder


if i have
A
   B
      BB
          file 0
   C
   file 1

to move to folder Z (all inside folder A),

move A Z works but moves the folder A
move a\* Z move only files inside A but not subfolders
0
 
ingeticAuthor Commented:
found it

cd %1

for /f "delims=" %%a in ('dir /b') do (
  move "%%a" %2
)
 cd ..

0
 
CetusMODCommented:
PAQed with points refunded (500)

CetusMOD
Community Support Moderator
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now