Problems With File Management

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Zack
Posts: 2
Joined: 02 Mar 2010 16:45

Problems With File Management

#1 Post by Zack » 02 Mar 2010 17:10

Hey guys,

I'm kinda struggling with a problem here. I hope someone has a solution. What I am trying to establish some code that would establish the drive letters. And then compare two folders against each other. I'm already set when it comes to copying the files. The problem is deleting the ones in the second folder that no longer exists in the first folder. I've tried simply deleting all the files period, however when it came time to update the files by copying I found it took too long.

Here's what I have so far:

@echo off
cd C:\Briefcase\

for %%p in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%p:\Briefcase\ set w=%%p

The main problem is that I need the function to be recursive so it can go throughout all the subfolders and delete all the unnecessary files. I've tried so many variables of the for function, but just can't figure out how to get a simple path without the drive letter. If I at least had the path without the drive letter I could then switch it with another one. I've even attempted to use the 'for /r' function which was just useless because I couldn't figure out how to get the a pathname without the drive letter.

Any suggestions would be greatly appreciated.

Thanks

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: Problems With File Management

#2 Post by avery_larry » 03 Mar 2010 10:58

I strongly recommend you look into the resource kit's robocopy command. Does just what you want, and in fact is one of the main reasons it was created.

Zack
Posts: 2
Joined: 02 Mar 2010 16:45

Re: Problems With File Management

#3 Post by Zack » 04 Mar 2010 18:44

Thanks for the reply. Tried it. Worked out great.

Post Reply