peter1234 Posted January 8, 2006 Share Posted January 8, 2006 I want to write back to the same folder that user uses to input a file, but I do not know what folder will be used. Is there any way to tell what folder a file is in other than by deleting characters from the end of the long file name until there is a backslash? I would think there would be a better way, but I can't find it. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 8, 2006 Moderators Share Posted January 8, 2006 I want to write back to the same folder that user uses to input a file, but I do not know what folder will be used. Is there any way to tell what folder a file is in other than by deleting characters from the end of the long file name until there is a backslash? I would think there would be a better way, but I can't find it. Huh? Ok... is it your Au3.exe your talking about? @ScriptDir should take care of that or @AutoItExe. If it is a file that your end-user is choosing from your program, why not store it in a variable? $Var = FileOpenDialog('Open File', @ScriptDir, 'All (*.*)') MsgBos(0, 'Info', $Var) Your question is an enigma really... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 8, 2006 Share Posted January 8, 2006 Can you clarify what you mean byfolder that user uses to input a fileWhat is this folder that the user is using. Like Smoke N said, is this the folder where the person is running the script? "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
peter1234 Posted January 8, 2006 Author Share Posted January 8, 2006 (edited) I am writing a program to convert an mpeg file to DVD files. The user can choose any mpeg file on his computer to be converted. I have no idea where these files will be stored on his computer. I would like to put the DVD files back in the same folder he has his mpeg file in. I currently put the DVD files on the desktop by using @DesktopDir. I can remove the characters from the end of the file name to find the folder, but I assume there is a user defined function (or some built in fuction) for doing this which would make the code cleaner. However, I have not been able to find such a function. It seems like this would be something used quite often. Edited January 8, 2006 by peter1234 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 8, 2006 Moderators Share Posted January 8, 2006 (edited) There's a UDF that should make that easy for you... look at _PathSplit in the help fileEdit... make sure it's the Beta Help File Edited January 8, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
peter1234 Posted January 8, 2006 Author Share Posted January 8, 2006 SmOke_N, Wow, how did you find that? Looks like it will work. Thanks. Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 8, 2006 Share Posted January 8, 2006 (edited) Like this: #include <file.au3> dim $szDrive, $szDir, $szFName, $szExt dim $path = "C:\windows\system32\calc.exe" $arrayPath = _PathSplit($path, $szDrive, $szDir, $szFName, $szExt) msgbox(0,"", $arrayPath[1] & $arrayPath[2]) Edited January 8, 2006 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
peter1234 Posted January 8, 2006 Author Share Posted January 8, 2006 Works fine. Thanks to both of you. Link to comment Share on other sites More sharing options...
John Posted January 9, 2006 Share Posted January 9, 2006 I want to write back to the same folder that user uses to input a file, but I do not know what folder will be used. Is there any way to tell what folder a file is in other than by deleting characters from the end of the long file name until there is a backslash? I would think there would be a better way, but I can't find it.I always use something like;$song="C:\My Documents\My Music\song.mp3"$location=StringMid($song,1,StringInStr($song, "\",0,-1)-1)MsgBox(0,$song,$location) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now