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/
>> > 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.
> > 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/
Only OP knows for sure what was meant by "compare names of files".
BTW, you have a % missing from the last %F. :O
> > > > 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/
I required in the second batch to compare name of files not contents
of file . When I tried FC command it compared contents like this :
F:\etisalat\batches>for %f in (F:\etisalat\batches\data\*.*) do fc %f
F:\etisalat\batches\new\*.*
F:\etisalat\batches>fc F:\etisalat\batches\data\1.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\1.txt and F:\ETISALAT\BATCHES
\NEW\1.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\2.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\2.txt and F:\ETISALAT\BATCHES
\NEW\2.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\3.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\3.txt and F:\ETISALAT\BATCHES
\NEW\3.txt
FC: no differences encountered
F:\etisalat\batches>fc F:\etisalat\batches\data\4.txt F:\etisalat
\batches\new\*.
*
Comparing files F:\ETISALAT\BATCHES\DATA\4.txt and F:\ETISALAT\BATCHES
\NEW\4.txt
FC: no differences encountered
But when I tried that batch below I got wrong results (wrong file
names not even exist in the folders mentioned in set statements
:
@echo off
set fldr1="F:\etisalat\batches\data"
set fldr2="F:\etisalat\batches\new"
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%)
)
)
Results:
:----------
data in "F:\etisalat\batches\data" and NOT in "F:\etisalat\batches
\new"
GOM PLAYEREN SETUP.EXE in "F:\etisalat\batches\data" and NOT in "F:
\etisalat\batches\new"
realalt182.exe in "F:\etisalat\batches\data" and NOT in "F:\etisalat
\batches\new"
new in "F:\etisalat\batches\new" and NOT in "F:\etisalat\batches
\data"
GOM PLAYEREN SETUP.EXE in "F:\etisalat\batches\new" and NOT in "F:
\etisalat\batches\data"
realalt182.exe in "F:\etisalat\batches\new" and NOT in "F:\etisalat
\batches\data"
>But when I tried that batch below I got wrong results (wrong file
>names not even exist in the folders mentioned in set statements
>:
>@echo off
> set fldr1="F:\etisalat\batches\data"
> set fldr2="F:\etisalat\batches\new"
> 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%)
> )
> )
Two errors: Your parentheses were mismatched
and for long filenames the "%%~nxA" term has to be double quoted
(this works below but the syntax that splits a path into multiple
double-quoted terms will not work with all Microsoft tools)
@echo off
set fldr1="F:\etisalat\batches\data"
set fldr2="F:\etisalat\batches\new"
for %%A in (%fldr1%\*.*) do (
if not exist %fldr2%\"%%~nxA" (
echo %%~nxA in %fldr1% and NOT in %fldr2%
divide.bat shows no results no moving is happenning :
Results:
------------
F:\etisalat\batches>divide
Moving files from "F:\etisalat\batches\data" to "F:\etisalat\batches
\data\1 "
md "F:\etisalat\batches\data\1 "
move "F:\etisalat\batches\data\1.txt" "F:\etisalat\batches\data\1 "
md "F:\etisalat\batches\data\1 "
move "F:\etisalat\batches\data\2.txt" "F:\etisalat\batches\data\1 "
md "F:\etisalat\batches\data\2"
move "F:\etisalat\batches\data\3.txt" "F:\etisalat\batches\data\2"
md "F:\etisalat\batches\data\2"
move "F:\etisalat\batches\data\4.txt" "F:\etisalat\batches\data\2"
Moving files from "F:\etisalat\batches\data" to "F:\etisalat\batches
\data\3"
Divide
------------
@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 "%new%\%DirName%"
for /F "tokens=*" %%* in (%new%\dir.txt) do (
if not exist "%Source%\!DirName!" echo md "%new%\!DirName!"
echo move "%Source%\%%*" "%new%\!DirName!"
set /a count=!count! + 1
if !count! GEQ %limit% (
set count=0
set /a DirName=!DirName! + 1
)
)
echo Moving files from "%Source%" to "%new%\!DirName!"
::del c:\dir.txt
>divide.bat shows no results no moving is happenning :
The echo in front of the move and md commands merely echo the commands to
the screen.
divide.bat is working fine to 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 "%new%\%DirName%"
for /F "tokens=*" %%* in (%new%\dir.txt) do (
if not exist "%Source%\!DirName!" md "%new%\!DirName!"
move "%Source%\%%*" "%new%\!DirName!"
:: if not exist "%Source%\!DirName!" echo md "%new%\!DirName!"
:: echo move "%Source%\%%*" "%new%\!DirName!"
set /a count=!count! + 1
if !count! GEQ %limit% (
set count=0
set /a DirName=!DirName! + 1
)
)
echo Moving files from "%Source%" to "%new%\!DirName!"
::del c:\dir.txt
But executing compare.bat results are wrong though the 2 directories
contains different files I got this :
F:\etisalat\batches>compare
data in "F:\etisalat\batches\data" and NOT in "F:\etisalat\batches
\new"
new in "F:\etisalat\batches\new" and NOT in "F:\etisalat\batches
\data"
I need to show the files that are in directory and in not in the other
directory .
compare.bat :
----------
@echo off
set fldr1="F:\etisalat\batches\data"
set fldr2="F:\etisalat\batches\new"
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%
)
)
Thanks