AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

retrieving a text from a file path

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
lost world
Guest





PostPosted: Wed Feb 17, 2010 4:34 pm    Post subject: retrieving a text from a file path Reply with quote

hi...how to retrieve xyz from the following path
C:\Documents and Settings\lostworld\Desktop\xyz.txt
well i read all string commands and i can work through specifying count or getpos.....but is their a way to detect last '\' ? so that anything after that can be retrieved in this case xyz.txt
if this is possible then is it possible now to get only xyz (excluding .txt)
Back to top
tonne



Joined: 06 Jun 2006
Posts: 1651
Location: Denmark

PostPosted: Wed Feb 17, 2010 4:46 pm    Post subject: Reply with quote

Code:
path := "C:\Documents and Settings\lostworld\Desktop\xyz.txt"
pos  := instr(path,"\", false, 0) ; 0 search backwards
msgbox % substr(path,pos+1) ; +1 skip \

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Wed Feb 17, 2010 4:57 pm    Post subject: Reply with quote

... get only xyz
Code:
F1=C:\Documents and Settings\lostworld\Desktop\xyz.txt
SplitPath,F1, name, dir, ext, name_no_ext, drive
msgbox,%name_no_ext%
return


or example go back (2)
Code:
F1=C:\Documents and Settings\lostworld\Desktop\xyz.txt
StringSplit,CX, F1,`\
X=2                                    ;-- minus 2 goback
C:=(CX0-X)
loop,%c%
  E =% E . CX%A_Index% . "\"
msgbox,C=%c%`nE=%E%                    ;-- (3) C:\Documents and Settings\lostworld\
return
Back to top
View user's profile Send private message
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Wed Feb 17, 2010 9:31 pm    Post subject: Reply with quote

emmm Splitpath anyone
Code:
OutNameNoExt     Name of the variable in which to store the file name without its path, dot and extension.
http://www.autohotkey.com/docs/commands/SplitPath.htm
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Feb 18, 2010 6:51 am    Post subject: Reply with quote

@tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys
Back to top
lostworld
Guest





PostPosted: Thu Feb 18, 2010 6:52 am    Post subject: Reply with quote

@tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group