There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Recursion with Folder Heirarchy Through Batch


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
screamoon's Avatar
Junior Member with 15 posts.
 
Join Date: Jul 2006
Experience: Beginner
20-Jul-2006, 09:46 AM #1
Recursion with Folder Heirarchy Through Batch
There were two issues that I was facing. So I would go step by Step.

ISSUE 1: suppose that I have a text file with contents as:
1)a
2)b
3)c
4)d

Now in some folder C:\Output I have some files with extension say .1

I want to delete all other files from that folder Output apart from the files listen in the Text file.

That means I want a script that would leave only those files which are listed in that text file and delete all others.

This issue got resolved with this script :


@echo
cd c:\output
PAUSE
for /f %%a in (C:\Files.txt) do attrib +h %%a
PAUSE
del /q c:\output\*.* /A-h
for /f %%a in (c:\Files.txt) do attrib -h %%a



ISSUE 2: Now what I want is that suppose in that folder output I have hierarchy of folders with names as
a, b , c, d, e....and so on.

Some of these folders might be empty whereas some of these might have some files or maybe another subfolder in it.


I want to write a script so that my above script checks into all the folders and if it finds that folder empty then it comes out and looks into next folder.

So in all all the folders get analysed and the files whose names were not there in the text file get deleted, whether those files belong to the subfolders or to the root folder. My script should analyze every folder.

I hope I am able to make you people understand what I am trying to do.


Please help.

Thanking you
scream
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:18 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.