Solved

script to run attrib command

Posted on 2006-06-14
5
518 Views
Last Modified: 2013-12-03
Hello,
I am looking for a script that will enumerate a certain set of folders
then run the attrib command to clear the Archive bit

The directory structure is like this:
Y:\files\a\a\aauser\profile
Y:\files\z\z\zzuser\profile

I was hoping to run the command on the 'profile' folder and all its contents
If it matters, the profile folder is always the same level deep in the directory structure

Thank you for any help you can give me
0
Comment
Question by:mdiglio
  • 2
  • 2
5 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 50 total points
ID: 16908654
The easiest way would probably be to

-------------->8-----------------
@echo off
attrib -A Y:\files\*.* /s
-------------->8-----------------

Are there any other constraints?
0
 
LVL 16

Author Comment

by:mdiglio
ID: 16908902
Yes, sorry I wasn't clear on the environment.
The profile folder is just one folder in the user's home directory
I need to leave other folders/files alone

I only want to reset the archive bit on the profile folders
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 450 total points
ID: 16909901

Hi,

This quick little VbScript will look for a folder called Profile and change the archive bit to off for that folder and everything beneath it. Is that what you're looking for?

Chris


Const ARCHIVE_BIT = 32
Const STARTING_FOLDER = "Y:\"

Dim objFileSystem, objFolder

Sub FindProfile(objFolder)
      Dim objSubFolder

      For Each objSubFolder in objFolder.SubFolders
            If LCase(objSubFolder.Name) = "profile" Then
                  SetArchiveBit objSubFolder
            Else
                  FindProfile objSubFolder
            End If
      Next
End Sub

Sub SetArchiveBit(objFolder)
      Dim objFile, objSubFolder

      If objFolder.Attributes And ARCHIVE_BIT Then
            objFolder.Attributes = objFolder.Attributes - ARCHIVE_BIT
      End If

      For Each objFile in objFolder.Files
            If objFile.Attributes and ARCHIVE_BIT Then
                  objFile.Attributes = objFile.Attributes - ARCHIVE_BIT
            End If
      Next
      For Each objSubFolder in objFolder.SubFolders
            If objSubFolder.Attributes And ARCHIVE_BIT Then
                  objSubFolder.Attributes = objSubFolder.Attributes - ARCHIVE_BIT
            End If
            SetArchiveBit objSubFolder
      Next
End Sub


Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSystem.GetFolder(STARTING_FOLDER)

FindProfile objFolder
0
 
LVL 16

Author Comment

by:mdiglio
ID: 16911110
Thank You; that is exactly what I wanted to do
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 16911418

Pleasure, glad I could help.

Chris
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question