PC Review


Reply
Thread Tools Rate Thread

2 Batches required

 
 
happytoday
Guest
Posts: n/a
 
      17th Jul 2008
I need to automate those 2 tasks :
1-Distribute number of files inside 1 directory to subdirectories
created each one include only 1000 file. All of them named
1,2,3...etc.
2-compare names of files inside 2 directories and see the different of
files .
Please help .
Thanks in advance .
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      17th Jul 2008

"happytoday" <(E-Mail Removed)> wrote in message
news:2b1cd825-1947-4dfb-b43e-(E-Mail Removed)...
>I need to automate those 2 tasks :
> 1-Distribute number of files inside 1 directory to subdirectories
> created each one include only 1000 file. All of them named
> 1,2,3...etc.
> 2-compare names of files inside 2 directories and see the different of
> files .
> Please help .
> Thanks in advance .


Try this:
1. Copy and paste the lines below into c:\Windows\happy.bat.
2. Adjust Line #05 to suit your environment.
3. Remove all line numbers.
4. Run the batch file.
5. If you're happy with the result you see on the screen, remove
the word "echo" from Lines #12 and #13.

I do not understand what you're trying to achieve with your second
question. Please elaborate.

01. @echo off
02. set limit=1000
03. set count=0
04. set DirName=1
05. set source=d:\Thu
06.
07. setlocal enabledelayedexpansion
08. dir /b "%source%\*.txt" > c:\dir.txt
09.
10. echo Moving files from "%Source%" to "%Source%\%DirName%"
11. for /F "tokens=*" %%* in (c:\dir.txt) do (
12. if not exist "%Source%\!DirName!" echo md "%Source%\!DirName!"
13. echo move "%Source%\%%*" "%Source%\!DirName!"
14. set /a count=!count! + 1
15. if !count! GEQ %limit% (
16. set count=0
17. set /a DirName=!DirName! + 1
18. echo Moving files from "%Source%" to "%Source%\!DirName!"
19. )
20. )
21. del c:\dir.txt


 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      17th Jul 2008
happytoday wrote:
> I need to automate those 2 tasks :
> 1-Distribute number of files inside 1 directory to subdirectories
> created each one include only 1000 file. All of them named
> 1,2,3...etc.
> 2-compare names of files inside 2 directories and see the different of
> files .
> Please help .
> Thanks in advance .


We will be glad to HELP you. So that we are not doing all of your work for
you, show us what you have written so far.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
Tom Lavedas
Guest
Posts: n/a
 
      17th Jul 2008
On Jul 17, 4:32 pm, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:
> happytoday wrote:
> > I need to automate those 2 tasks :
> > 1-Distribute number of files inside 1 directory to subdirectories
> > created each one include only 1000 file. All of them named
> > 1,2,3...etc.
> > 2-compare names of files inside 2 directories and see the different of
> > files .
> > Please help .
> > Thanks in advance .

>
> We will be glad to HELP you. So that we are not doing all of your work for
> you, show us what you have written so far.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)


Well - I know where you're coming from, but my biggest problem is that
the problems are pretty loosely defined - maybe an English as a second
(or third) language issue.

The second one is pretty easy to write, but hard to imagine for a less
than intermediate batch writer, so I took a crack (using NT/2K/XP/
Vista(?) approach) ...

@echo off
set fldr1="D:\Folder 1"
set fldr2="X:\Folder 2"
for %%A in (%fldr1%\*.*) do (
if not exist %fldr2%\%%~nxA (
echo %%~nxA in %fldr1% and NOT in %fldr2%)
)
)
for %%A in (%fldr2%\*.*) do (
if not exist %fldr1%\%%~nxA (
echo %%~nxA in %fldr2% and NOT in %fldr1%)
)
)

This can be done in no NT variant OSs, need to forgo the use of the
parentheses and CD into the folder under test before each of the FOR
statements. If the folders are on different drive it requires another
trick or two. But I leave that to a follow up (if there is one).

I didn't touch the first one without OPs input (code and or more
explanation of what is trying to be accomplished.)

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      18th Jul 2008
On Thu, 17 Jul 2008 14:00:10 -0700 (PDT), Tom Lavedas <(E-Mail Removed)>
wrote:

>> > I need to automate those 2 tasks :
>> > 1-Distribute number of files inside 1 directory to subdirectories
>> > created each one include only 1000 file. All of them named
>> > 1,2,3...etc.


>I didn't touch the first one without OPs input (code and or more
>explanation of what is trying to be accomplished.)


I figure the OP wants a series of folders inside the current folder named
1,2,3,4...n that each contain 1000 files. The files are to be moved from
the current folder.

 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      18th Jul 2008
foxidrive wrote:
> Tom Lavedas wrote:
>
> >> > I need to automate those 2 tasks :
> >> > 1-Distribute number of files inside 1 directory to subdirectories
> >> > created each one include only 1000 file. All of them named
> >> > 1,2,3...etc.

>
> >I didn't touch the first one without OPs input (code and or more
> >explanation of what is trying to be accomplished.)

>
> I figure the OP wants a series of folders inside the current folder named
> 1,2,3,4...n that each contain 1000 files. The files are to be moved from
> the current folder.


Sounds about right but ISTM is a easily handled(manually) one time
operation.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
Richard Bonner
Guest
Posts: n/a
 
      18th Jul 2008
Tom Lavedas ((E-Mail Removed)) wrote:

> > happytoday wrote:
> > > I need to automate those 2 tasks :
> > > 1-Distribute number of files inside 1 directory to subdirectories
> > > created each one include only 1000 file. All of them named
> > > 1,2,3...etc.
> > > 2-compare names of files inside 2 directories and see the different of
> > > files .


> The second one is pretty easy to write, but hard to imagine for a less
> than intermediate batch writer, so I took a crack (using NT/2K/XP/
> Vista(?) approach) ...


> @echo off
> set fldr1="D:\Folder 1"
> set fldr2="X:\Folder 2"
> for %%A in (%fldr1%\*.*) do (
> if not exist %fldr2%\%%~nxA (
> echo %%~nxA in %fldr1% and NOT in %fldr2%)
> )
> )
> for %%A in (%fldr2%\*.*) do (
> if not exist %fldr1%\%%~nxA (
> echo %%~nxA in %fldr2% and NOT in %fldr1%)
> )
> )


> This can be done in no NT variant OSs, need to forgo the use of the
> parentheses and CD into the folder under test before each of the FOR
> statements. If the folders are on different drive it requires another
> trick or two. But I leave that to a follow up (if there is one).


> Tom Lavedas


*** Hmm, can't this be done in one line? I am thinking of something such
as:

FOR %%F IN (*.*) DO FC %%F path\%F


Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

 
Reply With Quote
 
Todd Vargo
Guest
Posts: n/a
 
      18th Jul 2008
Richard Bonner wrote:
> Tom Lavedas wrote:
>
> > > happytoday wrote:

....
> > > > 2-compare names of files inside 2 directories and see the different

of
> > > > files .

>
> > The second one is pretty easy to write, but hard to imagine for a less
> > than intermediate batch writer, so I took a crack (using NT/2K/XP/
> > Vista(?) approach) ...

>
> > @echo off
> > set fldr1="D:\Folder 1"
> > set fldr2="X:\Folder 2"
> > for %%A in (%fldr1%\*.*) do (
> > if not exist %fldr2%\%%~nxA (
> > echo %%~nxA in %fldr1% and NOT in %fldr2%)
> > )
> > )
> > for %%A in (%fldr2%\*.*) do (
> > if not exist %fldr1%\%%~nxA (
> > echo %%~nxA in %fldr2% and NOT in %fldr1%)
> > )
> > )

>
> > This can be done in no NT variant OSs, need to forgo the use of the
> > parentheses and CD into the folder under test before each of the FOR
> > statements. If the folders are on different drive it requires another
> > trick or two. But I leave that to a follow up (if there is one).

>
> > Tom Lavedas

>
> *** Hmm, can't this be done in one line? I am thinking of something such
> as:
>
> FOR %%F IN (*.*) DO FC %%F path\%F


Only OP knows for sure what was meant by "compare names of files".

BTW, you have a % missing from the last %F. :O

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

 
Reply With Quote
 
Richard Bonner
Guest
Posts: n/a
 
      19th Jul 2008
Todd Vargo ((E-Mail Removed)) wrote:
> Richard Bonner wrote:


> > > > happytoday wrote:
> > > > > ...compare names of files inside 2 directories and see the
> > > > > difference of files.


> > *** Hmm, can't this be done in one line? I am thinking of something such
> > as:
> >
> > FOR %%F IN (*.*) DO FC %%F path\%F


> Only OP knows for sure what was meant by "compare names of files".


*** True. I took it to mean the differences of the contents of
like-named files.


> BTW, you have a % missing from the last %F. :O
> --
> Todd Vargo


*** Oh, so I did. Thanks for picking me up on that.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/
 
Reply With Quote
 
happytoday
Guest
Posts: n/a
 
      19th Aug 2008
On Jul 17, 8:41*pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "happytoday" <ehabaziz2...@gmail.com> wrote in message
>
> news:2b1cd825-1947-4dfb-b43e-(E-Mail Removed)...
>
> >I need to *automate those 2 tasks :
> > 1-Distribute number of files inside 1 directory to subdirectories
> > created each one include only 1000 file. All of them named
> > 1,2,3...etc.
> > 2-compare names of files inside 2 directories and see the different of
> > files .
> > Please help .
> > Thanks in advance .

>
> Try this:
> 1. Copy and paste the lines below into c:\Windows\happy.bat.
> 2. Adjust Line #05 to suit your environment.
> 3. Remove all line numbers.
> 4. Run the batch file.
> 5. If you're happy with the result you see on the screen, remove
> * * the word "echo" from Lines #12 and #13.
>
> I do not understand what you're trying to achieve with your second
> question. Please elaborate.
>
> 01. @echo off
> 02. set limit=1000
> 03. set count=0
> 04. set DirName=1
> 05. set source=d:\Thu
> 06.
> 07. setlocal enabledelayedexpansion
> 08. dir /b "%source%\*.txt" > c:\dir.txt
> 09.
> 10. echo Moving files from "%Source%" to "%Source%\%DirName%"
> 11. for /F "tokens=*" %%* in (c:\dir.txt) do (
> 12. * if not exist "%Source%\!DirName!" echo md "%Source%\!DirName!"
> 13. * echo move "%Source%\%%*" "%Source%\!DirName!"
> 14. * set /a count=!count! + 1
> 15. * if !count! GEQ %limit% (
> 16. * * set count=0
> 17. * * set /a DirName=!DirName! + 1
> 18. * * echo Moving files from "%Source%" to "%Source%\!DirName!"
> 19. * *)
> 20. )
> 21. del c:\dir.txt


I tried that a sample version but not working with me :

@echo off
set limit=2
set count=0
set DirName=1
set source=F:\etisalat\batches\data
set new=F:\etisalat\batches\new

setlocal enabledelayedexpansion
dir /b "%source%\*.txt" > %new%\dir.txt

echo Moving files from "%Source%" to "%Source%\%DirName%"
for /F "tokens=*" %%* in (%new%\dir.txt) do (
if not exist "%Source%\!DirName!" echo md "%Source%\!DirName!"
echo move "%Source%\%%*" "%Source%\!DirName!"
set /a count=!count! + 1
if !count! GEQ %limit% (
set count=0
set /a DirName=!DirName! + 1
)
)
echo Moving files from "%Source%" to "%Source%\!DirName!"
::del c:\dir.txt
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incomplete Batches =?Utf-8?B?cmljaGFyZA==?= Microsoft Access Queries 6 1st Aug 2007 03:44 PM
Using ADO.NET to prcoess T-SQL batches =?Utf-8?B?RGF2aWQgUiBIYW5jb2Nr?= Microsoft ADO .NET 4 4th May 2004 08:16 AM
Burning batches on cds Dave Windows XP General 2 28th Jan 2004 05:41 PM
burning cd batches Dave Wray Windows XP Basics 2 22nd Jan 2004 02:00 AM
printing in batches doobrie Microsoft Windows 2000 Printing 0 1st Nov 2003 03:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 PM.