How can I make a batch file affect its own folder and all subfolders?

0
3
Asked By CuriousCoder92 On

I'm working on a batch file to hide files created by my video editor, specifically files with the extensions .bak, .sfk0, .sfk1, .sfk2, and .sfk3. The current code I have looks like this:

attrib +h *.bak
attrib +h *.sfk0
attrib +h *.sfk1
attrib +h *.sfk2
attrib +h *.sfk3

However, I want it to also apply these attributes to all subfolders within the folder where the batch file resides. I've only been able to find commands that display subfolders but not alter them directly.

2 Answers

Answered By BatchBoss34 On

You can use the `/s` option with your `attrib` command to include subfolders. Just adjust your commands like this:

attrib +h *.bak /s
attrib +h *.sfk0 /s
attrib +h *.sfk1 /s
attrib +h *.sfk2 /s
attrib +h *.sfk3 /s

This will hide those files in the current directory and all of its subfolders. By the way, if you ever want to learn more about any command, just add `/?` after it, like this: `attrib /?`. Happy coding!

Answered By FileManagementFan On

Just a thought: why are you hiding those files instead of deleting them? If they’re temporary and your editor doesn’t clear them, it might slow things down. It could be worth considering deleting them after you're done with your video editing. Just a suggestion!

CuriousCoder92 -

If I delete them, my video editor needs to rebuild the peaks every time I open a project, which wastes time.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.