WLGades Posted December 14, 2004 Posted December 14, 2004 I'm trying to rename all the files in a directory given the directory name. So if the directory name is "1023", and the files are called "a.csv", "b.csv", and "c.csv", I want "a 1023.csv", "b 1023.csv", and "c 1023.csv" after I've run the script. So, I've figured out how to get all the files in a directory from the help file, and I know I can use FileMove to rename the file, but how do I actually get the directory name from the path description? I looked through the library with little success.
MHz Posted December 14, 2004 Posted December 14, 2004 $array = StringSplit('c:\1023\a.csv', '\') $result = $array[0] - 1 MsgBox(4096,'debug:' , '$answer:' & $array[$result]) Here is an example. StringSplit splits the address by the back slashes, and turns it into an array. We just extract the 2nd last entry in the array to find out the directory name.
kanumi Posted December 14, 2004 Posted December 14, 2004 You may have to split the filename into it's parts.http://www.autoitscript.com/fileman/users/Valik/path.au3 may help.Or search the forum for "splitpath"
WLGades Posted December 14, 2004 Author Posted December 14, 2004 The problem is that requires your knowing the entire path name before running it. Is there any way to get the path name of the files that are being returned? Or even the path of the currently executing AutoIt script?You may have to split the filename into it's parts.http://www.autoitscript.com/fileman/users/Valik/path.au3 may help.Or search the forum for "splitpath"<{POST_SNAPBACK}>
kanumi Posted December 14, 2004 Posted December 14, 2004 (edited) @ScriptDir @WorkingDir You can set the working dir to something relative to it's current value and it will be updated with the absolute path. FileChangeDir ( "..\" ) msgbox(0, "Test", @WorkingDir) Edited December 14, 2004 by kanumi
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