Solved

script to run attrib command

Posted on 2006-06-14
5
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 71

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 71

Expert Comment

by:Chris Dent
ID: 16911418

Pleasure, glad I could help.

Chris
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

756 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