Monthly Archives: November 2016

Updating Attributes via command line

http://www.howtogeek.com/205910/how-to-change-file-attributes-with-attrib-from-the-windows-command-prompt/

.

What Attributes Can You Use?

Now that you have your elevated command prompt window open, you will need to know what types of attributes you can edit using the “attrib” tool. There are two main types of attributes, “basic” and “extended.”

Basic Attribute Switches (R, H, A, S)

  1. R – This command will assign the “Read-Only” attribute to your selected files or folders.
  2. H – This command will assign the “Hidden” attribute to your selected files or folders.
  3. A – This command will prepare your selected files or folders for “Archiving.”
  4. S – This command will change your selected files or folders by assigning the “System” attribute.

“Attrib” Syntax

You will need to know the proper syntax to use for the “attrib” tool before you get started.

ATTRIB [+ attribute | - attribute] [pathname] [/S [/D]]

In this syntax, you will need to know what the different switches and parameters represent.

  1. The + and – indicate whether you will activate or deactivate the attribute specified.
  2. The attributes you can use are those explained above.
  3. The “/S” signifies that you want to search the entire path specified including subfolders for a particular file.
  4. The “/D” signifies that you want to include any process folders as well.
  5. The pathname indicates the location of your target folder or file. The proper syntax for path files is shown below.
Drive and/or filename - C:\*.* OR C:\Users\Owner\Desktop\samplefile.txt

If you decide not to specify any of the attributes listed above, the files or folders will revert to their current attribute settings.

Fast Deletion of files and folders in Windows

Deleting with Windows Explorer is rubbish because it wastes lots of time enumerating the files. I usually move the stuff I need to delete to C:\stufftodelete and have a deletestuff.bat batch file to rmdir /s/q C:\stufftodelete. This is scheduled to run at night, but sometimes I need to run it during the day so the quicker the better.

Here’s the results of a quick time test of a small 5.85 MB sample of 960 files in 303 folders. I ran method 1 followed by method 2, then reset the test directories.

Method 1 removes the files and directory structure in one pass:

rmdir /s/q foldername

Method 2 has a first pass to delete files and outputs to nul to avoid the overhead of writing to screen for every singe file. A second pass then cleans up the remaining directory structure:

del /f/s/q foldername > nul
rmdir /s/q foldername
  • Method 1: 17.5s, 14.9s, 13.9s, 14.8s, 13.8s: average 14.98 seconds
  • Method 2: 14.3s, 12.1s, 11.7s, 14.2s, 11.8s: average 12.82 seconds

Here’s results of another test using 404 MB of 19,521 files in 3,243 folders:

  • Method 1: 2 minutes 20 seconds
  • Method 2: 2 minutes 33 seconds

So there’s not much in it, probably too close to judge on a single test.


Edit: I’ve retested with much more data, this is a typical case for me: 28.3 GB of 1,159,211 files in 146,918 folders:

  • Method 1: 2h 15m, 2h 34m: average: 2 hours 25 minutes
  • Method 2: 49m, 57m: average: 53 minutes