How to open multiple folders in a specific order using batch file? Windows 10

Currently I use the below script but it doesn't open the folders in the given order. It opens the folders in a random order.

@echo off
start explorer "Folder 1 Path"
start explorer "Folder 2 Path"
start explorer "Folder 3 Path"
start explorer "Folder 4 Path"
8

4 Answers

You can use timeout command in middle of every command. Use timeout /t 2, if you want timeout to stay quiet, timeout /t 2 >nul. It should work. Just make your code like this:

@echo off
start explorer "Folder 1 Path"
timeout /t 2 >nul
start explorer "Folder 2 Path"
timeout /t 2 >nul
start explorer "Folder 3 Path"
timeout /t 2 >nul
start explorer "Folder 4 Path"

Thanks

Using a for loop listing in order would be...

@echo off
for %%i in ( "%UserProfile%\Desktop" "%UserProfile%\Documents" "%UserProfile%\Downloads" "%UserProfile%\Pictures" )do start "" "%%~i"

Chain it together on one line.

start "" "folder1"|start "" "folder2"|start "" "folder3"
1

This is the .bat file content:

for /F "usebackq tokens=*" %%A in ("dirs.txt") do explorer %%A
  • You need to create the file dirs.txt which contains the full path of the directories respectively

This is an example of "dirs.txt" file content:

C:\Users\User\Desktop\1
C:\Users\User\Desktop\2
C:\Users\User\Desktop\3
C:\Users\User\Desktop\New Folder

Edit1:

usebackq is used to handle folders with white spaces.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like