I use a software to backup my HDD to an other HDD. The sofware finds the differences first and mirrors them to the backup HDD then. Unfortunatelly, it ignores the folders' system attributes. This is a problem, because a lot of the folders have modified icons, that are displayed only if the folders' system attributes are set.
To correct this, I want to find all the affected folders. These are the ones that contain a desktop.ini file, so the system attributes should be set of such folders.
I know how to set the system attribute of a folder, but I don't know how to do it recursively, conditionally:
D:\>attrib +s ExampleDirectory
I guess I'll need a Windows batch script, but I'm not sure, as I don't know anything about batch programming.
If you really want to stick to your backup tool, which apparently cannot handle attributes correctly, you could use the following code based on
for/D /Rto reapply theSystemattribute for all directories that contain a fileDesktop.ini:The two nested
ifstatements are required to apply theSystemattribute for directories that contain a file calledDesktop.ini, but not for those that contain a directory of that name (although this might occur quite unlikely); the firstifcondition matches both files and directories, the second one doesnotmatch directories (note the trailing\).Anyway, perhaps you should switch to another backup tool that can handle all attributes correctly, like robocopy, for example, which has been recommended by a comment.
The above approach does not handle hidden items correctly, because
for /Ddoes not recognise hidden directories, andattribdoes not change the System attribute of hidden files. To overcome this, the code needs to be modified like this:This makes use of the
~amodifier of theforvariable reference and sub-string replacement.