Loop through Dirs in a batch file

May 16, 2006 at 10:58:10
Specs: XP, x86 Intel

Hi there,
I need to write some kind of script/batch file that will go through each directories &
subdirectories (except hidden directory) and then perform some CVS command (add) for
each of the directories using probably for loop or anything else.
Does anybody know how to do this?

Any help would be gratefully received.

See More: Loop through Dirs in a batch file

Report •

May 16, 2006 at 12:27:33

What version of DOS and what is a CVS command?

If at first you don't succeed, you're about average.


Report •

May 16, 2006 at 13:00:55

You appear to have posted in the incorrect forum, this forum is primarily concerned with MS-DOS and compatable O/S.

XP is based on NT O/S and therefore either the Programming Forum or XP Forum would be more appropriate and reach a wider user base of NT O/S users......


COMMAND.COM = NT VIRTUAL DOS MACHINE (loosely based on MS-DOS 5/6/7/8) actually it is akin to Emulating an O/S on a different platform

Report •

May 16, 2006 at 20:05:31

When you post the question in the programming area, you should include more info on what you want to accomplish with CVS.

Are you trying to take a snapshoot of the contents of each dir and add that to a new file to upload to CVS? If so, you probably want to do a CVS update instead of CVS add.

Report •

Related Solutions

May 16, 2006 at 20:08:12


If at first you don't succeed, you're about average.


Report •

May 16, 2006 at 20:10:58


Here's some info on CVS - Concurrent Versions System


Report •

May 16, 2006 at 20:18:04

Hi FM,


BTW, do you have a synyax checker for c/c++?

Seems like the kind of thing perl would be very good at.

If at first you don't succeed, you're about average.


Report •

May 16, 2006 at 20:48:32

Hi M2,

A couple days ago I started teaching myself Visual C++.net and am using its IDE, but I haven't gotten very far. I'm thinking about doing 2 versions of ramsniffer for David, 1 Perl and 1 C++.

Report •

May 17, 2006 at 15:52:12

No actually I'm trying to add new files into the server using the CVS command.For those who dont know CVS,doesnt matter.What's more important is for me to know how to go through each folder/directories+subdirectories,take this files inside them and perform some action (let's say I want to open all files).

I'm using the FOR loop command
i.e: FOR /R %f IN (".") DO CD %f
but this command will go through all directories including the one that is hidden.
I'm not sure what DOS version I'm using but typing "VER" on cmd I get this:
Microsoft Windows XP [Version 5.1.2600]

Thank you so much

Report •

May 17, 2006 at 17:25:02

Using CVS just to add (copy) new files to the server seems to me to be an odd use of CVS. Using scp, rsync or ftp would be more appropriate.

Key point to remember is that there is no DOS in XP. It doesn't matter to me, but others in this topic area some people get very bothered when someone asks an XP batch file qustion.

I can't help with the batch file, but if you're interested, I can show you a Perl script.

Here are 2 Perl modules that I would use to traverse the directories and execute the CVS command.

File::Find - Traverse a directory tree.

Cvs - Object oriented interface to the CVS command

Report •

May 18, 2006 at 10:46:19

I am trying to copy all changed files from FTP into company's server without losing old copies (that's why I'm using CVS).
I think I should have post this message on CVS's forum instead of here.But thank you for the help.

Report •

May 18, 2006 at 11:54:13

That makes a little more sense, but it seams to me that if you're going to use add, you also need to put them in a different directory in the repository, otherwise you'll probably be overwritting the prior file. That's why I suggested using update instead of add.

The main/first thing we need to look at is what language do you want to use. A batch file could be used, but it would no be a very good choice. Next we'd need a little more detail on what you need to accomplish. Do you need to CVS/add each entire directory, or just certian files within the directory? If it's just certian files, do you want/need to compare them against the ones in the repository before adding?

Very few people on this site, especially in the DOS area, don't know much about CVS. I do use CVS for versioning some of my scripts, so if you like, I can help with a perl script but not a batch file. Or, I can point you to other sources.

Report •

May 18, 2006 at 12:19:38

It'd be very nice of you to help.

I need to use 'add & commit' command too because I am trying to add all files and directories found on the FTP into the repository that I create on the server.

So the step I actually need to perform is:
1. Copy files from FTP into the CVS client's local folder
2. Using CVS, update sandbox with the recent files from the server.
3. Compare if there're any differences found between the current file from the repository against the one from the FTP.
4. If there're any changes/differences then perform an CVS command (add & commit) to this file.

I am very new with perl but I will try my best to work with it.
Thank you so much in advance.

Report •

Ask Question