Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

script to run attrib command

Posted on 2006-06-14
5
Medium Priority
?
529 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 200 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 1800 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 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