jjppark Posted August 24, 2006 Share Posted August 24, 2006 I'm sure there is a simple explanation that I'm just not seeing. I need to include in my script a file copy to a destination path which includes several variable characters. That is, the last part of the path contains characters which vary from user to user. The following did not work successfully: $szFile = "c:\prefs2.txt" $workingdir = "C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\*.default\" FileCopy($szFile, $workingdir) The wildcard represents the part of the directory which changes from user to user. Please help. Thanks in advance. Link to comment Share on other sites More sharing options...
BPBNA Posted August 24, 2006 Share Posted August 24, 2006 You would have to have a way to check which user unless your trying to copy it into all the users folder, in which case you could use FileFindFirstFile and FileFindNextFile I beleive. Link to comment Share on other sites More sharing options...
Geeky Posted August 24, 2006 Share Posted August 24, 2006 Whats the .default for? I'm not very experienced with autoit, but i'm pretty sure its not supposed to look like that. Whats the meaning of having the .default there? Link to comment Share on other sites More sharing options...
BPBNA Posted August 24, 2006 Share Posted August 24, 2006 The .default, I'm assuming, is the file extension that its going to have. Is this correct? Link to comment Share on other sites More sharing options...
lod3n Posted August 24, 2006 Share Posted August 24, 2006 Try this; #Include <File.au3> $szFile = "c:\prefs2.txt" $workingdir = "C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\" $FolderList=_FileListToArray($workingdir,"*.default",2) If (Not IsArray($FolderList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf for $i = 1 to $FolderList[0] $folder = $workingdir & $FolderList[$i] FileCopy($szFile, $folder) Next [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 The .default, I'm assuming, is the file extension that its going to have. Is this correct?The ".default" is the part of the directory name that is constant. Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 Whats the .default for?I'm not very experienced with autoit, but i'm pretty sure its not supposed to look like that. Whats the meaning of having the .default there?The ".default" is the part of the directory name that is constant. Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 You would have to have a way to check which user unless your trying to copy it into all the users folder, in which case you could use FileFindFirstFile and FileFindNextFile I beleive.The directory I listed is actually a single directory on each workstation. I want to copy the file into this directory (I'm running from a login script) except I only know the last portion of the directory name...the ".default" portion. Link to comment Share on other sites More sharing options...
lod3n Posted August 24, 2006 Share Posted August 24, 2006 Perhaps you could show a few examples of what end result you are looking for, are you saying: c:\prefs2.txt > C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\prefs2.default c:\prefs1.txt > C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\prefs1.default [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 Perhaps you could show a few examples of what end result you are looking for, are you saying:c:\prefs2.txt > C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\prefs2.defaultc:\prefs1.txt > C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\prefs1.defaultSure:c:\prefs.txt > C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\xpfcn5m2.default\prefs.txtThe "xpfcn5m2" is the portion that varies and is the part I was representing with a wildcard character.Thanks again for helping me figure this out. Link to comment Share on other sites More sharing options...
lod3n Posted August 24, 2006 Share Posted August 24, 2006 The code I posted before should handle this. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 The code I posted before should handle this.Excellent. I'll give it a try. Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 Try this; #Include <File.au3> $szFile = "c:\prefs2.txt" $workingdir = "C:\Documents and Settings\jjp\Application Data\Thunderbird\profiles\" $FolderList=_FileListToArray($workingdir,"*.default",2) If (Not IsArray($FolderList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf for $i = 1 to $FolderList[0] $folder = $workingdir & $FolderList[$i] FileCopy($szFile, $folder) Next Am I wrong or is the _FileListToArray not a defined AutoIt3 function? I can't seem to find reference to it. Link to comment Share on other sites More sharing options...
jjppark Posted August 24, 2006 Author Share Posted August 24, 2006 Am I wrong or is the _FileListToArray not a defined AutoIt3 function? I can't seem to find reference to it.I see that I had to use Beta 3 to get access to that function. Tried it...works great. Thanks for the help! Link to comment Share on other sites More sharing options...
lod3n Posted August 24, 2006 Share Posted August 24, 2006 Oops, sorry. I should have mentioned it. I keep falsely assuming everyone updates as compulsively as I do. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] 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