Jump to content

Dos 6.22 For


Recommended Posts

Have a need to use For in Dos 6.22 and wondering if someone can tell me how to copy some files.

Heres the situation

I 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 overwrite

For %%A in (H:\Main\*.*) Do Copy /Y H:\Main\%%A C:\Data1
For %%A in (H:\Main\*.*) Do Copy /Y H:\Sheets\%%A C:\Data2

Does that look correct or someone with Dos skills can help me out here?

Link to comment
Share on other sites


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 by maxXPsoft
Link to comment
Share on other sites

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

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. :unsure:

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

I didn't put all the Paths there and its only a 10 Mhz. :wacko: 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 this

H:

CD SHOPMFG

CD SECOND~1

CD COOPER~1

CD NUMBER06

For %%A in (*.*) Do Copy H:\SHOPMFG\SECOND~1\COOPER~1\Sheets\%%A C:\2WND\DATA_2 /Y

By CD to actual dir the variable %%A becomes filename only and these are 8.3 names

MHz,

I'll look at using that because I actually need to do 3 operations here.

Copy the Number## file to Data_1

Copy corresponding Sheets file to Data_2

Delete 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 by maxXPsoft
Link to comment
Share on other sites

@jaclaz

Yeah, 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.

@maxXPsoft

I 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 off
CD /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"
)
pause

You 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 by MHz
Link to comment
Share on other sites

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_2

by 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, :no: 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

spoke too soon. can't get that forune.exe to run inside a batch so back to other method

Can't use with this dos (

)

Can't use CD with the /D either

H:
CD SHOPMFG\SECOND~1\COOPER~1\NUMBER01
For %%A in (*.*) Do Copy H:\SHOPMFG\SECOND~1\COOPER~1\Sheets\%%A C:\2WND\DATA_2 /Y
CD H:\ <<< puts it back to root. CD H: just echos your current dir
C:

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

Can't use with this dos (

)

Can't use CD with the /D either

I 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...