Reputation: 401
So I want to access this specific path
c:\users\admin\social\profile\KoJumperz\pictures
but my friends name isn't KoJumperz
so his path is not the same. His path would be
C:\users\admin\social\profile\JhonSmith\pictures
Is there a way to create a code that will open the first folder in my profile folder?
Upvotes: 0
Views: 3005
Reputation: 73566
Start enumerating the folders and break the loop after the first iteration:
for /d %%d in (C:\users\admin\social\profile\*) do (set profile=%%d & goto break)
:break
echo Using %profile%\pictures
To get the 2nd folder skip 1 entry of dir listing:
for /f "skip=1 delims=" %%d in ('dir /b /a:d "C:\users\admin\social\profile\*"') do (
set profile=%%d
goto break
)
:break
Use skip=2
to get the 3rd and so on.
Or find an environment variable that may be set on the user's PC, for example %socialusername%
(the exact variable name can be seen by running set
in command prompt console):
echo Using C:\users\admin\social\profile\%socialusername%\pictures
Upvotes: 1