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

June 29, 2025 2 answers
Asked by CuriousCoder92
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.

Answers

FileManagementFan
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.

Reply to this answer
BatchBoss34
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!
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions