Batch File To Convert System Files Into Regular Files
In the video below, I walk you through steps you can take to create a Batch File that removes the System File attribute from all files in any folder. If you are familiar with batch files and wish to skip the video the syntax is simply:
For %%x In (*.*) Do attrib -s -h /s
Echo, Echo, /R
For the sake of brevity in the video, I omitted the “@Echo off” command from the beginning of the batch file. Not sure what this does? Hit this link to learn more this useful command.
The For loop can also be enhanced by making it loop through any child folders nested within the one you are working on. You can make the For loop ‘recursive’ by adding a /r switch. This line of code would look like this: For %%x /r In (*.*) Do attrib -s -h /s.
An Alternative Method – and why I don’t use it
Although the “remove” command is quite simple to type into the command prompt I have been toying with a method that runs the batch script direct from the folder without having to enter the CMD at all. What I did instead was to assign the batch script to the right-click shortcut menu in Windows Explorer; I could then run the batch file in Explorer from a shortcut in the white-space of my SecretFiles folder. Two clicks and all the system files become visible.
I used the following method to achieve this:
- Open up RegEdit and back up the registry
- Navigate to HKCR/Directory/Background/shell and create a key (the name of the key is the name you want shown in the right-click menu)
- Create a Key within your new key and call it “command” (all lower case)
- Double click the “Default” value in the command key and set the data value to the path of your batch file (in quotes, e.g. “c:/bat/remove.bat”)
- Close RegEdit and test it out
While this method worked just fine for me when I tried it, the main drawback to using it is that it can only be used in the white-space within the Contents area of Explorer. If you attempt to use it from one of the folders in the folder area, CMD will default to c:\windows\system32 and will attempt to remove the System File attribute from all files in this folder. This would obviously be bad news, so I want to hide the link to the batch file when right-clicking folders in both the Contents area and the Folders area of Explorer. Sadly showing a menu item in the white-space but not in the folder list doesn’t appear to be possible within Windows.
If you are interested in using RegEdit to create or remove items from context menus, then there is a full explanation here.
Posted on February 27, 2012, in Files & Folders and tagged "Batch Scripts", Desktop, Hidden File, Hidden File Attribute, How-To, Microsoft Windows, RegEdit, Tutorial, Windows. Bookmark the permalink. Leave a Comment.