0

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
  • Insert some delay (1-2s) between the commands. For example...
    – Akina
    Commented Oct 25, 2021 at 6:51
  • 1
    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
    – Head
    Commented Oct 25, 2021 at 6:53
  • @Akina How do I add time delays?
    – RvidD
    Commented Oct 25, 2021 at 16:29
  • 1
    You must add a command provided by @Jhon between each pair of your start commands. PS. Really you do not need in start, you may execute explorer "Folder N Path" only.
    – Akina
    Commented Oct 25, 2021 at 16:57
  • 1
    @RvidD Sure, I will
    – Head
    Commented Oct 26, 2021 at 7:24

4 Answers 4

2

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

1

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"

1

Chain it together on one line.

start "" "folder1"|start "" "folder2"|start "" "folder3"
1
  • When seeing this answer, I thought it will work. But it opens the folders in random order :(
    – RvidD
    Commented Nov 3, 2021 at 9:41
0

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
  • Unfortunately, as-is, this suffers from the same issue that OP is trying to resolve. You could add the necessary timeouts into the loop, of course. Commented Oct 25, 2021 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .