Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using MSDOS to move 'x' number of files

Posted on 2006-07-22
8
Medium Priority
?
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
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.

618 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