maxXPsoft Posted February 23, 2008 Share Posted February 23, 2008 Have a need to use For in Dos 6.22 and wondering if someone can tell me how to copy some files.Heres the situationI have a folder on the Network called Main and another called Sheets.As files are updated they are placed in Main for a machine to download. Can be 1 or 20 possibly and None are named the same. I need to copy the identical file from Sheets also.Yes they are named identical but they go to different folders on the Hard drive like Data1 and data2. One is a machine print and other is for the user.This will be in a batch file so %% is required. And if a file exists we overwriteFor %%A in (H:\Main\*.*) Do Copy /Y H:\Main\%%A C:\Data1For %%A in (H:\Main\*.*) Do Copy /Y H:\Sheets\%%A C:\Data2Does that look correct or someone with Dos skills can help me out here? Link to comment Share on other sites More sharing options...
jaclaz Posted February 23, 2008 Share Posted February 23, 2008 Point is, is there a reason why not using xcopy?http://www.csulb.edu/~murdock/xcopy.htmljaclaz Link to comment Share on other sites More sharing options...
maxXPsoft Posted February 23, 2008 Author Share Posted February 23, 2008 (edited) I use xcopy now but have to do it by date /D:02/20/2008 to get the Sheets folder files since after I copy from Main they are deleted untill next update which can occur anytime. These are old and don't keep date very well.Is there a way to use xcopy to get the files that are in main only from Sheets folder also? Sheets is nearly 7500+ files and needs to be done quickly only grabbing Sheets files that are in Main also since they are updated same time.This is ver 6.2 xcopy in Dos on a whopping 25Mhz with 1mb ram so copy entire folders is sssssllllllllllooooowwow. Edited February 23, 2008 by maxXPsoft Link to comment Share on other sites More sharing options...
jaclaz Posted February 24, 2008 Share Posted February 24, 2008 Well, then, yes, the:For %%A in (H:\Main\*.*) Do Copy /Y H:\Main\%%A C:\Data1For %%A in (H:\Main\*.*) Do Copy /Y H:\Sheets\%%A C:\Data2Should work allright.jaclaz Link to comment Share on other sites More sharing options...
MHz Posted February 25, 2008 Share Posted February 25, 2008 It would seem possible to change the 2 loops into just one. I see no sense in using 2 loops with the same loop condition.For %%A in (H:\Main\*.*) Do ( Copy /Y H:\Main\%%A C:\Data1\ Copy /Y H:\Sheets\%%A C:\Data2\) Link to comment Share on other sites More sharing options...
jaclaz Posted February 25, 2008 Share Posted February 25, 2008 Yep, but if, for any reason, H:\Main and H:\Sheets are "far apart" physically on the drive, the seeking back and forth may be increased. I would test both solutions with the same set of files and see if there is a noticeable difference in speed, the hardware specs appear to be extremely low.jaclaz Link to comment Share on other sites More sharing options...
maxXPsoft Posted February 25, 2008 Author Share Posted February 25, 2008 (edited) I didn't put all the Paths there and its only a 10 Mhz. We only have 5 left.Couldn't use above because For %%A in (H:\Main\*.*) turns into the Full path for the variable so that fails.so Had to use thisH:CD SHOPMFGCD SECOND~1CD COOPER~1CD NUMBER06For %%A in (*.*) Do Copy H:\SHOPMFG\SECOND~1\COOPER~1\Sheets\%%A C:\2WND\DATA_2 /YBy CD to actual dir the variable %%A becomes filename only and these are 8.3 namesMHz, I'll look at using that because I actually need to do 3 operations here.Copy the Number## file to Data_1Copy corresponding Sheets file to Data_2Delete the Number## file so next time there are less. Bad here is while its still on H: it creates a funky file AHEIVOP or similar but that may have been Xcopy I was using on that folder.By CD.. all the way back to C: that don't happen. Also need the path to be back to C: for load of next 2 programs anyways and need H: to be at root. Edited February 25, 2008 by maxXPsoft Link to comment Share on other sites More sharing options...
MHz Posted February 25, 2008 Share Posted February 25, 2008 (edited) @jaclazYeah, I agree that seek times could be a problem under certain conditions. And probably being a FAT filesystem could hinder performance some. For NTFS, seeking is affected by having to read the MFT each time and returning to the location of where the file is, so seek maybe not much of a performance hit.@maxXPsoftI am not sure how much you can do with DOS 6.22 since long ago that I used. But you do have some other options available with switches to enhance the usage of CD or other commands. And if long filename support is available then using quotes may help.An example of using the /D switch with CD allows you to change the current working directory to another drive.@echo offCD /D "D:\"For %%A in ("*.*") Do ( Echo Main gets "D:\%%A" Echo Sheets gets "D:\%%A")CD /D "C:\"For %%A in ("*.*") Do ( Echo Main gets "C:\%%A" Echo Sheets gets "C:\%%A")pauseYou may even look at using PushD and PopD if suitable.And this may work for you though I am getting some what lost with understanding your paths now.CD /D "H:\SHOPMFG\SECOND~1\COOPER~1"For %%A in ("Main\*.*") Do ( Copy /Y "Main\%%A" "C:\Data1\" Copy /Y "Sheets\%%A" "C:\Data2\")CD /D "C:\" Edited February 25, 2008 by MHz Link to comment Share on other sites More sharing options...
jaclaz Posted February 25, 2008 Share Posted February 25, 2008 The above makes me wonder......you could use SUBST:http://www.computerhope.com/substhlp.htmto map the \Main and the \Sheets to a "plain" drive letter.jaclaz Link to comment Share on other sites More sharing options...
maxXPsoft Posted February 26, 2008 Author Share Posted February 26, 2008 Found the best thing - Fortune.exe part of fortn708 package.Its a tuner for the Dos For command and works great.fortune in H:\ShopMfg\Second~1\cooper~1\number01\*.* Do Copy H:\ShopMfg\Second~1\cooper~1\Sheets\%R.%E C:\2Wnd\Data_2by running that I get a batch file with all commands and it even deletes the doit.bat at end of execution.The %R.%E extracts just filename and you can do all kinds of things with it. I can run that from C: drive without any hitch.Those Paths aren't mine, it where I work and the guy before me should have made it short path knowing he had Dos machines out there. Link to comment Share on other sites More sharing options...
maxXPsoft Posted February 26, 2008 Author Share Posted February 26, 2008 spoke too soon. can't get that forune.exe to run inside a batch so back to other methodCan't use with this dos ()Can't use CD with the /D eitherH:CD SHOPMFG\SECOND~1\COOPER~1\NUMBER01For %%A in (*.*) Do Copy H:\SHOPMFG\SECOND~1\COOPER~1\Sheets\%%A C:\2WND\DATA_2 /YCD H:\ <<< puts it back to root. CD H: just echos your current dirC:Check out what I am doing with the CD here, it works so I'll use it. Some day they'll update these things but that was put on back burner to do other stuff. Link to comment Share on other sites More sharing options...
MHz Posted February 27, 2008 Share Posted February 27, 2008 Can't use with this dos ()Can't use CD with the /D eitherI thought there maybe some limitations in that environment. Just do a 2nd For loop for the "Main" folder if needed. Your last attempt looks like you are on track. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now