Solved

Using MSDOS to move 'x' number of files

Posted on 2006-07-22
8
437 Views
Last Modified: 2012-05-05
Hello....

Brush off the dust!.....I need to use a DOS command using CMD inside Windows.

I have a folder with a huge amount of files.
I moved ALL of them to a temp folder.
Now I want to move SOME back.
How would I move, say 100 at a time?

This would move ALL of the files...
move c:\Temp\*.eml c:\Mail\

How would I move just a portion.
I can key off of file dates if necessary.

Thanks,

---- Mike


0
Comment
Question by:MikeCombe
8 Comments
 
LVL 13

Expert Comment

by:haim96
ID: 17160735
you need to move specific files  or it dos't matter ?
0
 

Author Comment

by:MikeCombe
ID: 17160912
Hi,

Not specific files.
Just need to move 'x' amount of files at a time.
Say 100 files, 1,000 files at a time.

Thanks,

---- Mike
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 17161195
The following script was adapted from http://www.ss64.com/nt/for.html.

Paste the lines below into a text file with a .cmd extension.  Adjust the value of the "limit" variable for the number of files you want to move.

@echo off
setlocal

set limit=101
set filecount=1

for %%G in (c:\temp\*.eml) do (call :_count "%%G")
goto :end

:_count
if %filecount%==%limit% goto :end
move "c:\temp\%1" c:\Mail\ /Y
set /a filecount+=1
goto :eof

:end
endlocal
0
 

Author Comment

by:MikeCombe
ID: 17161235
Hi,

This looks exactly like what I wanted....however...
I get the error....

"goto was unexpected at this time."

any ideas?

Thanks,

---- Mike
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 17161266
Hmm, looks like I made a couple of mistakes.  Try this:

@echo off
setlocal

set filecount=1
set limit=101

for %%G in (c:\temp\*.eml) do (call :_count "%%G")
goto :end

:_count
if %filecount%==%limit% goto :end
move /Y %1 c:\Mail
set /a filecount+=1
goto :eof

:end
endlocal
0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 17161756
xcopy \\loc1\drive\dirs\*.*  \\loc2\drive\dirs\  /r/h/k/s/e/c/d

the d is the date parameter, it will only update newer files, and it will leave all the others alone.

When all files are done, then --

del \\loc1\drive\dirs\*.* /Y

This is the only safe way to do it in DOS.  Batch files are fine for anything but a move.  Because if you dont make sure the file is copied before you delete it, you will lose some, as batch files can always be interrupted or go awry.  I have lost many files with automated batch files including delete.  take my advice, and dont do it.  Copy them all first, then verify the directories are the same size or bigger on the target, and only AFTER you have done this, then delete the source files.
0
 
LVL 2

Expert Comment

by:yyilmaz
ID: 17165047
You can use a VBS script as well.
If you are interested I can find / write you a script.
0
 

Author Comment

by:MikeCombe
ID: 17165145
Hi yyilmaz,

Thanks for the offer....much appreciated.

--- Mike
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello I read in a discussion about a person who configured a very simple mirror RAID with two hard drives; the system and data were on the same partition. He asked how to repair the system as it was not booting up anymore. In his case running …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now