[XP] Automating "Hidden" status for a particular file extension

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Hello all, more Windows scripting.

As users of Office will know, you can ste it to automagically create back up files of your documents with various additional file extensions: .wbk for Word backups for instance.

Basically, though I want the backup, I'm fed up of them appearing in my folders alongside the real thing. I'd like to know they're there for "if I need them".

Is there a way to set all files with the extension to be hidden, and better still to set all new files with that extension to be hidden as well?

I'm doubting that it is, which means that my alternative is to schedule a script to periodically scan my Documents directory for backup files and change their hidden attribute for me.
The "attrib" command should do the changing of the file permission, it's just a case of getting it to grab the appropraite files.

EDIT~ OK - done it. It's a useful little script though, so here it is to share:

Code:
attrib +H D:\bmpw\Documents\*.wbk /S

+H adds the Hidden attribute.
/S checks all sub folders.
To get the full list of switches, type the usual:
Code:
attrib /?

One thing that I'm still interested in though and which isn't answered for me by just reading the attrib help text is how to get it to search for multiple file extensions in one go?

For instance, Excel backups and text file backups all have different extensions and I want to hide them as well, do I need to have a script repeatedly calling the above attrib command line or is there a regular expression-like syntax for entering multiple filenames all at once, and save searching the filesystem 5 or 6 times?

Thanks.

Ben
 

phlash

Fledgling Freddie
Joined
Dec 24, 2003
Messages
195
I had a quick look at the 'for' command syntax (which is waaay too complicated these days!), but nothing does regex the way you need it too. You can specify multiple file patterns in the search dialogue, so perhaps a macro recorder script that searches for all extensions you want, then selects all files found and changes attributes would do it?

A GUI-less version would require some programming in another scripting languge that can actually traverse directory contents (eg: Perl!).

Phil.
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Perl could be a good option. I can do a bit of that :)

Thank you :)
 

Users who are viewing this thread

Top Bottom