Solved

move command in dos

Posted on 2011-03-02
4
424 Views
Last Modified: 2012-05-11
im in the root folder. in this root folder are 10 subfolders. i want to move every that has a doc ext to a specific folder. how? is there a switch somewhere ? thanks

move *.doc e:\targetfolder\doc
0
Comment
Question by:miamiLAW
  • 2
4 Comments
 
LVL 11

Expert Comment

by:dekkar
ID: 35023928
Dont think move command has the capability...

I do know robocopy can.....

For example:

http://www.mydigitallife.info/2007/05/07/robocopy-syntax-command-line-switches-and-examples/


adding the /mov switch will delete copied files from the source.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 35023951
Try this from the DOS command line:

for /r "c:\root" %A in ("*.doc") do move "%A" "e:\targetfolder\doc"

Open in new window

~bp
0
 
LVL 8

Expert Comment

by:PeteEngineer
ID: 35023962
@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

Open in new window

0
 
LVL 8

Accepted Solution

by:
PeteEngineer earned 500 total points
ID: 35023965
if you want to move folders you have to use

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

then use DELTREE on the old one.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question