# Move Folders



## TechnoBlast (Mar 1, 2005)

I know how to move files, but what is the DOS command to move foldes?

For example, I have folders and files in the c:\sam\john directory. I want to move all the files and folders that are located in the JOHN directory into F:\backup directory.

Thanks.


----------



## devil_himself (Apr 7, 2007)

Here Ya Go


```
@echo off
setlocal
set source=c:\sam\john
set dest=F:\backup
pushd "%source%"
for /f "delims=" %%a in ('dir /b /ad 2^>NUL') do move /Y "%%a" "%dest%"
for /f "tokens=*" %%a in ('dir /b /a-d 2^>NUL') do move /y "%%a" "%dest%"
popd
endlocal
```


----------



## TechnoBlast (Mar 1, 2005)

devil_himself said:


> Here Ya Go
> 
> 
> ```
> ...


Thanks for the code.

Looks like it partially worked. Only the files were moved. The folders stayed in place. When I execute it I get an "Access is denied" message.

Any ideas?


----------



## devil_himself (Apr 7, 2007)

Which Os ?


----------



## DaveBurnett (Nov 11, 2002)

see XCOPY http://www.computerhope.com/xcopyhlp.htm

then use DELTREE on the old one.


----------

