Jump to content

BACTH - set folder within folder as variable ?


Recommended Posts

so heres my problem;

in this specific case, but would be nice even for any future problem in any way...

waterfox profile folder is this:
"%HOMEDRIVE%%HOMEPATH%\AppData\Local\Waterfox\Profiles"

but on every new pc the default user profile folder is garbled mesh and always different generated
in my current install it is named c5prw4uk.default
(so full path is "%HOMEDRIVE%%HOMEPATH%\AppData\Local\Waterfox\Profiles\c5prw4uk.default")

my question is, how to make within BAT/CMD script, so when you do DIR /A:D (to show only directories)
that name of that folder which is displayed gets set in %variable so i can do cleaning of
c5prw4uk.default\cache\*.*

anyone understood ? :D

Edited by vinifera
Link to comment
Share on other sites


I am not sure to understand fully, however:

@ECHO OFF
SETLOCAL 
FOR /F "tokens=* delims=" %%A IN ('DIR /A:D /B "%HOMEDRIVE%%HOMEPATH%\AppData\Local\Waterfox\Profiles\" ^|FIND /I ".default"') DO SET myvar="%%~dpnxA\cache\*.*"
SET myvar

should do.

This will only work if there is only one .default directory, or if there are more than one it will get the variable set to the last one

jaclaz

  • Like 1
Link to comment
Share on other sites

Sure, remove or REM the line

SET myvar

(that was made to let you check visually that it worked as expected)

Also as is it was intended to be a line in a more complex batch, so you might need to remove the
SETLOCAL

line to have the myvar definition "static" in the environment.

jaclaz

Link to comment
Share on other sites

i hate to be one of those guys :P

but i just noticed this, if full path is "%HOMEDRIVE%%HOMEPATH%\AppData\Local\Waterfox\Profiles\random.garbage.folder\cache"

but variable returns "%HOMEDRIVE%%HOMEPATH%\random.garbage.folder\cache"
(so \appdata\local\waterfox\profiles) is missing :/

maybe i can ease the calculation of ...something.,
I just need the random.garbage.folder name, not the full path, nor anything after
(dunno if that makes it easier for you)

 

Edited by vinifera
Link to comment
Share on other sites

The:
SET myvar="%%~dpnxA\cache\*.*"

Is not really-really carved in stone, try replacing it with

SET myvar="%%~nxA"

this should be only the name and extension of the folder which contain ".default".

Or try:

SET myvar="%HOMEDRIVE%%HOMEPATH%\AppData\Local\Waterfox\Profiles\%%~nxA\cache\*.*"

Now you see the usefulness of the

SET myvar

line, don't you? ;)

As a side note I doubt it is the "correct" way   (remember you asked for this) to find the name of that folder, I mean, unless Waterfox has some peculiar encrypted/encoded way of storing its settings, that folder name and path is written *somewhere*, either in a .ini (or .config file or similar or in the Registry as Waterfox needs obviously to know it, so the more "proper" approach would be to read it  from where it is written, instead of using the (subject to possible errors/conflicts/collisions/whatever) DIR /A:D approach.

jaclaz

 

Edited by jaclaz
  • Like 1
Link to comment
Share on other sites

Quote

Now you see the usefulness of the

SET myvar

i use ECHO %myvar% :D

Quote

As a side note I doubt it is the "correct" way   (remember you asked for this) to find the name of that folder

i think firefox classic does this, coz PaleMoon makes same thing, and i use Waterfox based on FF classic (not proton)

 

ALSO --- THANK YOU SO MUCH :D

Edited by vinifera
Link to comment
Share on other sites

12 hours ago, vinifera said:

i think firefox classic does this, coz PaleMoon makes same thing, and i use Waterfox based on FF classic (not proton)

Sure, whatever does that, it also reads that, so that path/directory name is written *somewhere* and the proper approach remains to read that same path/directory (*wherever* it is written) INSTEAD of using the DIR | FIND ".default", which is intrinsecally prone to error in case of name collision.

12 hours ago, vinifera said:

ALSO --- THANK YOU SO MUCH :D

You are welcome :)

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

you were right

in appdata\roaming\waterfox\profiles.ini

[Profile0]
Path=Profiles/c5prw4uk.default

 

but dont make nothing...
since i dont need nothing more than you already did and it works perfectly !

Edited by vinifera
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...