Guest happytoday Posted July 17, 2008 Posted July 17, 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 .
Guest Pegasus \(MVP\) Posted July 17, 2008 Posted July 17, 2008 Re: 2 Batches required "happytoday" <ehabaziz2001@gmail.com> wrote in message news:2b1cd825-1947-4dfb-b43e-201cd8df6451@c58g2000hsc.googlegroups.com... >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
Guest Todd Vargo Posted July 17, 2008 Posted July 17, 2008 Re: 2 Batches required 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)
Guest Tom Lavedas Posted July 17, 2008 Posted July 17, 2008 Re: 2 Batches required 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/
Guest foxidrive Posted July 18, 2008 Posted July 18, 2008 Re: 2 Batches required On Thu, 17 Jul 2008 14:00:10 -0700 (PDT), Tom Lavedas <tglbatch@cox.net> 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.
Guest Todd Vargo Posted July 18, 2008 Posted July 18, 2008 Re: 2 Batches required 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)
Guest Richard Bonner Posted July 18, 2008 Posted July 18, 2008 Re: 2 Batches required Tom Lavedas (tglbatch@cox.net) 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/
Guest Todd Vargo Posted July 18, 2008 Posted July 18, 2008 Re: 2 Batches required 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)
Guest Richard Bonner Posted July 19, 2008 Posted July 19, 2008 Re: 2 Batches required Todd Vargo (tlvargo@sbcglobal.netz) 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/
Guest happytoday Posted August 19, 2008 Posted August 19, 2008 Re: 2 Batches required 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-201cd8df6451@c58g2000hsc.googlegroups.com... > > >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
Guest happytoday Posted August 19, 2008 Posted August 19, 2008 Re: 2 Batches required On Jul 20, 1:32 am, ak...@chebucto.ns.ca (Richard Bonner) wrote: > Todd Vargo (tlva...@sbcglobal.netz) 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 Bonnerhttp://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"
Guest Pegasus \(MVP\) Posted August 19, 2008 Posted August 19, 2008 Re: 2 Batches required "happytoday" <ehabaziz2001@gmail.com> wrote in message news:f969ca53-f9ba-453a-b5a5-953b2b96140c@25g2000hsx.googlegroups.com... 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-201cd8df6451@c58g2000hsc.googlegroups.com... > > >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 ================ You write "I tried that a sample version but not working with me". This doesn't tell me anything. Remember - I can't see your screen, hence you need to be a lot more specific. I also suggest you reply quickly. You started this thread five weeks ago and it is about to disappear from my newsreader's horizon.
Guest foxidrive Posted August 19, 2008 Posted August 19, 2008 Re: 2 Batches required On Mon, 18 Aug 2008 23:59:25 -0700 (PDT), happytoday <ehabaziz2001@gmail.com> wrote: >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% ) ) for %%A in (%fldr2%\*.*) do ( if not exist %fldr1%\"%%~nxA" ( echo %%~nxA in %fldr2% and NOT in %fldr1% ) )
Guest happytoday Posted August 20, 2008 Posted August 20, 2008 Re: 2 Batches required On Aug 19, 3:45 pm, foxidrive <got...@woohoo.invalid> wrote: > On Mon, 18 Aug 2008 23:59:25 -0700 (PDT), happytoday > > > > > > <ehabaziz2...@gmail.com> wrote: > >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% > ) > ) > for %%A in (%fldr2%\*.*) do ( > if not exist %fldr1%\"%%~nxA" ( > echo %%~nxA in %fldr2% and NOT in %fldr1% > ) > )- Hide quoted text - > > - Show quoted text - 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
Guest foxidrive Posted August 20, 2008 Posted August 20, 2008 Re: 2 Batches required On Wed, 20 Aug 2008 07:35:56 -0700 (PDT), happytoday <ehabaziz2001@gmail.com> wrote: >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. >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
Guest happytoday Posted August 22, 2008 Posted August 22, 2008 Re: 2 Batches required On Aug 19, 3:45 pm, foxidrive <got...@woohoo.invalid> wrote: > On Mon, 18 Aug 2008 23:59:25 -0700 (PDT), happytoday > > > > > > <ehabaziz2...@gmail.com> wrote: > >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% > ) > ) > for %%A in (%fldr2%\*.*) do ( > if not exist %fldr1%\"%%~nxA" ( > echo %%~nxA in %fldr2% and NOT in %fldr1% > ) > )- Hide quoted text - > > - Show quoted text - 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
Recommended Posts