Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

script to run attrib command

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

927 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