Solved

Using MSDOS to move 'x' number of files

Posted on 2006-07-22
8
432 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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 …
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

759 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

22 Experts available now in Live!

Get 1:1 Help Now