?
Solved

Using MSDOS to move 'x' number of files

Posted on 2006-07-22
8
Medium Priority
?
489 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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
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.
Suggested Courses

765 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