Author Topic: How do I find the location of MyDocuments folder?  (Read 11883 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #15 on: April 19, 2011, 10:05:32 PM »
I'd probably go with the SpecialFolders object
Why, is the system variable too simple?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #16 on: April 20, 2011, 06:17:42 AM »
 :-D  Wow! you guys ran with this one.  :-D

I'd probably go with the SpecialFolders object
Why, is the system variable too simple?
Not for me it isn't.  It curls up very nicely inside my simple mind.
The more complex methods is for more complex minds.
 :-D :-D

Thanks again guys.

I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

laidbacklarry

  • Guest
Re: How do I find the location of MyDocuments folder?
« Reply #17 on: April 20, 2011, 08:14:53 AM »
Nostalgia? maybe.

On the other hand... there are some things you can do faster and easier in DOS. Our application includes a simple command - DOS - which opens a DOS window. If I can get a user to DOS, I can tell him/her Type this, Type that... and before you know it, we've done what needs to be done. I tell a user to open "Windows Explorer" and they almost always start "Internet Explorer"...

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: How do I find the location of MyDocuments folder?
« Reply #18 on: April 20, 2011, 08:46:21 AM »
I am a comand prompt junkie (well that comes froms being a *nix user though too).

AutoCAD conversations:
"type in: sh <enter> <enter> ..."
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #19 on: April 20, 2011, 08:58:41 AM »
Okay next question.  
LOCALROOTPREFIX gives me this = "C:\\Users\\Ted Krush\\AppData\\Local\\Autodesk\\ACA 2010\\enu\\"

Is there something out there that will get me this = "C:\\Users\\Ted Krush\\AppData\\Local  <=== back  slashes can be present or not.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How do I find the location of MyDocuments folder?
« Reply #20 on: April 20, 2011, 09:03:20 AM »
getenv TMP or TEMP may get you close  :wink:

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #21 on: April 20, 2011, 09:14:33 AM »
What Lee said:


(substr (getenv "Temp") 1 (vl-string-search "\\Temp" (getenv "Temp")))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #22 on: April 20, 2011, 09:18:00 AM »
getenv TMP or TEMP may get you close  :wink:
FYI: That will abbreviate the folder names if they are too long.

eg.
Code: [Select]
Command: (getenv "Tmp")
"C:\\Users\\ATHOMP~1\\AppData\\Local\\Temp"
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #23 on: April 20, 2011, 11:20:18 AM »
What Lee said:


(substr (getenv "Temp") 1 (vl-string-search " \\Temp"(getenv "Temp")))

Okay how did you do that?  and by that I mean tell to "delete" the " \\Temp" from the string?

The vl-string-search function searches the string not deletes from my reading the help file on vl-string-search. 

<sigh> I wish the help was little more dynamic when it comes to holding my hand.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #24 on: April 20, 2011, 11:22:36 AM »
What Lee said:


(substr (getenv "Temp") 1 (vl-string-search " \\Temp"(getenv "Temp")))

Okay how did you do that?  and by that I mean tell to "delete" the " \\Temp" from the string?

The vl-string-search function searches the string not deletes from my reading the help file on vl-string-search. 

<sigh> I wish the help was little more dynamic when it comes to holding my hand.
Look at the substr in the beginning of the call.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #25 on: April 20, 2011, 11:26:39 AM »
Look at the SUBSTR function (which does the trimming)

(vl-string-search " \\Temp"(getenv "Temp")) returns a number where the string "\\Temp" starts.

SUBSTR starts at a point in a string (in this case the beginning (1)) then stops at the beginning of "\\Temp" which was returned by the vl-string-search.

Maybe this will help you see it:


Code: [Select]
(setq string (getenv "Temp"))
;;If "\\Temp" is found in string
(if (setq p (vl-string-search "\\Temp" string))
  ;;Trim the string
  (substr string 1 p)
  ;;Else return the full string
  string
)


« Last Edit: April 20, 2011, 11:31:32 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #26 on: April 20, 2011, 11:37:01 AM »
Ahh the search is returning numerical position of where \\Temp starts in the string.

Me gets it now.  Thanks again.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #27 on: April 20, 2011, 11:53:43 AM »
Ahh the search is returning numerical position of where \\Temp starts in the string.

Me gets it now.  Thanks again.


:) Glad to help out.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #28 on: April 26, 2011, 04:02:06 PM »
How do I trim the right side of a sting to certain known character with unknown characters in between.

Quote
"\\\\server\\users\\ted krush\\my documents\\Folder name varies\\ To be trimmed but folder name also varies \\"

I can not get either vl-string-right-trim or Substr functions to fit.

I am trying to slice it and dice it using this ginzo code and it not working.
Code: [Select]
  (setq OldUserFolder1 (vl-filename-directory (findfile "acad.pgp")))
  (setq OldUserFolder2 (vl-string-right-trim "\\" OldUserFolder1))

A little push please?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #29 on: April 26, 2011, 04:50:22 PM »
If I understand the question look into this:
(vl-string-position char-codestr [start-pos [from-end-p]])
Arguments

char-code
The integer representation of the character to be searched.

str
The string to be searched.

start-pos
The position to begin searching from in the string (first character is 0); 0 if omitted.

from-end-p
If T is specified for this argument, the search begins at the end of the string and continues backward to pos


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC