Solved

Using MSDOS to move 'x' number of files

Posted on 2006-07-22
8
442 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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
 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
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.

776 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