No announcement yet.

File Set Attributes using attrib

  • Filter
  • Time
  • Show
Clear All
new posts

  • File Set Attributes using attrib

    I have a project that copies a bunch of files from the cd to a folder on the hard drive.

    My problem is when it copies them, it puts the read only attribute on them. So, I wanted to change all of the attributes after they have been copied, but AMS will only do it one at a time. It says in the help file that I can use a file execute action to run the attrib command, and that I can use wildcards. I don't know much about the attrib command, but I tried to follow it's usage instructions, and didn't get anywhere. So my main questions are

    1. What is the comand I would use to remove the read only attribute from all files in all folders contained in a folder?
    Example attrib -r c:\games\Galactic Battlegrounds\*.* etc.
    This is how I understood I should do it after reading the instructions when I typed attrib /? at the command prompt like the help suggested.
    2. How do I run the attrib command from the file execute action, and where does all the -r /s etc. stuff go?
    3. Can I use a variable in the path to the folder?

    I checked a bunch of dos help sites, and tried all of their examples, but could not get it to work.


  • #2
    Re: File Set Attributes using attrib

    Ok, a short update
    using my command line, I figured out how to use the attrib command. I have gotten it to work. Now I just need to know how to run the same command (attrib -r c:\folder\folder\*.* /s) from within autoplay, using a variable for the drive & path.
    Anybody got any ideas?


    • #3
      Re: File Set Attributes using attrib

      This seems to work but not if there are spaces in the directory Path. Not sure about long file names either. Just copy whats below and paste in your project:

      <Name>On Mouse Over</Name>
      <Name>On Mouse Leave</Name>
      <Name>On Mouse Click</Name>
      <Action name="Set Value">
      <Action name="Execute">
      <CommandLine>-r %dirpath%\*.* /s</CommandLine>
      <NormalColor format="decimal">0</NormalColor>
      <HighlightColor format="decimal">16711680</HighlightColor>
      <MouseDownColor format="decimal">255</MouseDownColor>


      • #4
        Re: File Set Attributes using attrib

        Just use the File.SetAttributes action in AMS. That is exactly what it is there for.


        • #5
          Re: File Set Attributes using attrib

          RobbyH wanted to use a wildcard to set the Attributes for mutiple files in a folder in one action.

          According to the AMS4 Help documentation the SetAttrib Action doesn't support Wildcards.

          Of course I didn't try it ..... Maybe I should.


          • #6
            Re: File Set Attributes using attrib

            You could use a While loop to execute the File.SetAttributes command. See the "Searching the desktop for text files" help topic for an example of a while loop that processes a set of files. It's the "clean" way to programatically do this task. Should work just fine.


            • #7
              Re: File Set Attributes using attrib

              It will work fine using the File - Execute action.

              File to execute: attrib.exe

              (or %SysDir%\attrib.exe to make it slightly faster)

              Command line arguments: -r "%dirpath%\*.*" /s

              (Note the quotes.)

              Replace %dirpath% with whatever variable the path is in...
              --[[ Indigo Rose Software Developer ]]


              • #8
                Re: File Set Attributes using attrib

                Lorne, your idea worked best. I considered the others, as they all would work, but using a .bat file was the easiest for a couple reasons.
                1. If the .bat file is in the main folder of all the files that need the attributes set, it takes only three simple lines.
                attrib -r *.* /s
                2. does not have to go into a lengthly loop if you have lots of
                Couple of things to remember. If you are running windows 2000, and it tells you proper attrib usage can include /d, don't do it, doesn't work on machines running win98, and maybe others. Also, if you have AMS set to wait for the .bat file to finish before continuing, remember to put in the close command, or your user may be sitting there a long time before they figure out they need to close the dos window(s). Again, this seems to be a win98 thing, my win 2000, closes these windows automatically.