Jump to content

My Documents folder through variable


Recommended Posts

Just on the off chance that the desktop.ini may help, here is the contents of the ones which may help. What are the differences with yours?

My Documents

[DeleteOnCopy]
Owner=<%UserName%>
Personalized=5
PersonalizedName=My Documents

My Music

[DeleteOnCopy]
Owner=<%UserName%>
Personalized=13
PersonalizedName=My Music
[.ShellClassInfo]
InfoTip=@Shell32.dll,-12689
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=-237

My Pictures

[DeleteOnCopy]
Owner=<%UserName%>
Personalized=39
PersonalizedName=My Pictures
[.ShellClassInfo]
InfoTip=@Shell32.dll,-12688
IconFile=%SystemRoot%\system32\mydocs.dll
IconIndex=-101

Obviously the username is variable, but may be part of the search criteria!

Link to comment
Share on other sites


Just on the off chance that the desktop.ini may help, here is the contents of the ones which may help. What are the differences with yours?

...

Obviously the username is variable, but may be part of the seargh criteria!

My Documents

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=126

My Music

[DeleteOnCopy]
Owner=Ben
Personalized=13
PersonalizedName=My Music
[.ShellClassInfo]
InfoTip=@Shell32.dll,-12689
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=-237

My Pictures

[.ShellClassInfo]
InfoTip=@Shell32.dll,-12688
IconFile=%SystemRoot%\system32\SHELL32.dll
IconIndex=127
[DeleteOnCopy]
Owner=Ben
Personalized=39
PersonalizedName=My Pictures

The desktop.ini from my computer is probably different since I have been synchronizing between my desktop and laptop computer.

Link to comment
Share on other sites

I don't know if its crucial that you have it search for some tag file in a directory (i.e. if you would have many PCs to do this on) or if you might be willing to consider alternatives (shortcuts you can get away with if number of PCs is small). But one idea that immediately came to mind on reading your post was that if you didn't have many variations on this (ie. perhaps you had 3 locations on different pcs something like: E:\blah1 , I:\HiddenInSomeHorriblyLongName\blah2 , & the default mydocs path) then you could easily get away with some if statements to check whether or not you custom locations exists and if not to use the default.

IF EXIST "E:\blah1" GOTO Type1
IF EXIST "I:\HiddenInSomeHorriblyLongName\blah2" GOTO Type2

:Add Conditions for Default MyDocs Here
maybe reg add something or other

:Type1

blahblahblah
GOTO Somewhere

:Type2
qwerty
GOTO Elsewhere

yeah... i know i'm lazy but you get the idea.

Don't know if you would want to use something like that but I'm fond of thinking of quick cheapies :whistle: if not then i'm sure somebody smarter than me will have a better answer for you... :P

Link to comment
Share on other sites

I don't know if its crucial that you have it search for some tag file in a directory (i.e. if you would have many PCs to do this on) or if you might be willing to consider alternatives (shortcuts you can get away with if number of PCs is small). But one idea that immediately came to mind on reading your post was that if you didn't have many variations on this (ie. perhaps you had 3 locations on different pcs something like: E:\blah1 , I:\HiddenInSomeHorriblyLongName\blah2 , & the default mydocs path) then you could easily get away with some if statements to check whether or not you custom locations exists and if not to use the default.

IF EXIST "E:\blah1" GOTO Type1
IF EXIST "I:\HiddenInSomeHorriblyLongName\blah2" GOTO Type2

:Add Conditions for Default MyDocs Here
maybe reg add something or other

:Type1

blahblahblah
GOTO Somewhere

:Type2
qwerty
GOTO Elsewhere

yeah... i know i'm lazy but you get the idea.

Don't know if you would want to use something like that but I'm fond of thinking of quick cheapies  :whistle:  if not then i'm sure somebody smarter than me will have a better answer for you...  :P

I actually thought of a batch script that could do it initially, but the problem is that I have NO CLUE whatsoever how to write such a batch.

That's why I turned here ;).

Since I'm not very good in all this scripting, batch-files, .exe files, and all that kind of stuff, please forgive me for the following question:

Is it really hard to code/create a program/script/batch/whatever that searches drives for a tag-file (at root or at root\somefolder) and if found, makes the necessary registry corrections? (Not taking into account a computer with multiple users).

Link to comment
Share on other sites

Is it really hard to code/create a program/script/batch/whatever that searches drives for a tag-file (at root or at root\somefolder) and if found, makes the necessary registry corrections? (Not taking into account a computer with multiple users).

To get you started, this batch will find all tagfiles on any drive. For your homework, just add the registry correction bit, select a suitable tagfile, and youre done :)

@echo off

set TAGFILE=desktop.ini

FOR %%D IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
 IF EXIST %%D:\NUL (
   echo Checking %%D:
   pushd "%%D:\"
   FOR /F "USEBACKQ DELIMS==" %%I IN (`DIR /S /B /a:h %TAGFILE%`) DO (
     echo Found tagfile "%%I"
   )
   popd
 )
)

pause

Link to comment
Share on other sites

To get you started, this batch will find all tagfiles on any drive. For your homework, just add the registry correction bit, select a suitable tagfile, and youre done :)

@echo off

set TAGFILE=desktop.ini

FOR %%D IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
 IF EXIST %%D:\NUL (
   echo Checking %%D:
   pushd "%%D:\"
   FOR /F "USEBACKQ DELIMS==" %%I IN (`DIR /S /B /a:h %TAGFILE%`) DO (
     echo Found tagfile "%%I"
   )
   popd
 )
)

pause

Thanks :).

A few questions concerning this though:

1. does this return a variable that I can use to put in the registry entry?

2. what does the "popd" do?

3. Why is the "NUL" in "IF EXIST %%D:\NUL"?

4. What does the "USEBACKQ DELIMS==" do?

Thanks again :).

Link to comment
Share on other sites

A few questions concerning this though:

1. does this return a variable that I can use to put in the registry entry?

2. what does the "popd" do?

3. Why is the "NUL" in "IF EXIST %%D:\NUL"?

4. What does the "USEBACKQ DELIMS==" do?

1. Nope. You could put the username in the tagfile and retrieve it with a FOR command.

2. Pushd changes to the specified directory. Popd returns to the original directory. Every pushd needs a corresponding popd.

3. NUL was required in older versions of MSDOS. It looks like its not required in WinXP batch files.

4. Usebackq changes the FOR command to process strings in back-quotes as commands (like Unix).

Delims== sets the delimiter to = so that filenames with spaces are not broken into words by default.

Type FOR /? in a command prompt window for more info.

Link to comment
Share on other sites

A few questions concerning this though:

1. does this return a variable that I can use to put in the registry entry?

2. what does the "popd" do?

3. Why is the "NUL" in "IF EXIST %%D:\NUL"?

4. What does the "USEBACKQ DELIMS==" do?

1. Nope. You could put the username in the tagfile and retrieve it with a FOR command.

2. Pushd changes to the specified directory. Popd returns to the original directory. Every pushd needs a corresponding popd.

3. NUL was required in older versions of MSDOS. It looks like its not required in WinXP batch files. But anyone booting with a Win98 floppy might need it.

4. Usebackq changes the FOR command to process strings in back-quotes as commands (like Unix).

Delims== sets the delimiter to = so that filenames with spaces are not broken into words by default.

Type FOR /? in a command prompt window for more info.

Is it possible then to have it return a variable that I can use in a regsistry-key?

Link to comment
Share on other sites

Put your username in a file called username.txt in your My Documents folder.

@echo off

set TAGFILE=username.txt

FOR %%D IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
IF EXIST %%D:\NUL (
  echo Checking %%D:
  pushd "%%D:\"
  FOR /F "USEBACKQ DELIMS==" %%I IN (`DIR /S /B %TAGFILE%`) DO (
    echo Tagfile: %%I
    for /F "usebackq delims==" %%J in ( "%%I" ) do (
      echo Username: "%%J"
      echo Directory: %%~dI%%~pI
    )
  )
  popd
)
)

pause

Link to comment
Share on other sites

Put your username in a file called username.txt in your My Documents folder.

@echo off

set TAGFILE=username.txt

FOR %%D IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
IF EXIST %%D:\NUL (
  echo Checking %%D:
  pushd "%%D:\"
  FOR /F "USEBACKQ DELIMS==" %%I IN (`DIR /S /B %TAGFILE%`) DO (
    echo Tagfile: %%I
    for /F "usebackq delims==" %%J in ( "%%I" ) do (
      echo Username: "%%J"
      echo Directory: %%~dI%%~pI
    )
  )
  popd
)
)

pause

OK, you totally lost me... :blushing:

Does it mean that I can use I%% in a registry entry so that My Documents is automatically set to the right directory?

I seriously have no clue... :whistle:

Thank you very much for your help though :thumbup

EDIT: OK, I've been doing some trying and that kind of things, seems to me that I only need something like

SET DOCSFOLDER=???

at the end, after the last closing ).

The only question is, what?

I've tried %%D, I've tried %%I, I've tried %%~dI%%~pI...

DOCSFOLDER should return the folder where it found the tagfile in...

Thanks again in advance.

Link to comment
Share on other sites

Edited above post, see there.

For completeness, the edit:

OK, I've been doing some trying and that kind of things, seems to me that I only need something like

SET DOCSFOLDER=???

at the end, after the last closing ).

The only question is, what?

I've tried %%D, I've tried %%I, I've tried %%~dI%%~pI...

DOCSFOLDER should return the folder where it found the tagfile in...

Thanks again in advance.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...