teeboi Posted May 3, 2011 Share Posted May 3, 2011 Looking for a script which will lookup for a file & replace it? Can someone please help me with this Link to comment Share on other sites More sharing options...
fett8802 Posted May 3, 2011 Share Posted May 3, 2011 Are you looking in a given set of folders? Or searching an entire drive? [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
BrewManNH Posted May 3, 2011 Share Posted May 3, 2011 Also, when you say you're looking to search for a file, and then replace it. Are you looking at the file name? Replacing it how? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
teeboi Posted May 3, 2011 Author Share Posted May 3, 2011 (edited) I am trying to replace a specific file in the following direcotry %APPDATA%\Mozilla\Firefox\Profiles\68miioew.default whereas 68miioew.default is different for all the users. How do i accomplish this? I am actually replacing this file from AppData & also from the program directory that is why i need a script which will search the file name lets say (abc.js) & replace. Edited May 3, 2011 by teeboi Link to comment Share on other sites More sharing options...
Jayson Posted May 3, 2011 Share Posted May 3, 2011 One way to do it is using FileSelectFolder then _FileListToArray to get all the content of it in an array. Link to comment Share on other sites More sharing options...
fett8802 Posted May 3, 2011 Share Posted May 3, 2011 I'm working on a quick script to give you an example, but I need to know what you are doing to each folder. Which of the following describes you? 1) You are replacing ALL profiles with a separate profile 2) You are checking to see which profile each user has and then doing something 3) Other [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
teeboi Posted May 3, 2011 Author Share Posted May 3, 2011 Looking for a abc.js file & replacing it from that directory & also from the p[rogram directory.. Not replacing the whole profile just the abc.js file Link to comment Share on other sites More sharing options...
fett8802 Posted May 3, 2011 Share Posted May 3, 2011 Well, I couldn't find an abc.js file, so I assume that's not the actual file name and as such I can't give you exactly what you need. However, here is the basic concept: #Include <File.au3> $aFolders =_FileListToArray("C:\Documents and Settings","*",2) ;This will list all of the folders in the main Documents and Settings folder $sCopyFolder = "Path to the folder to be copied" ;This is the path to the folder you wish to be copied For $i = 1 To UBound($aFolders) - 1 ;This will repeat for each profile folder $sFolder = "C:\Documents and Settings\" & $aFolders[$i] & "\Application Data\Mozilla\Firefox\Profiles\" ;The location of each individual profiles folder If FileExists($sFolder) = 1 Then ;Check to see if the given user has a Firefox profile folder, if so, then $aFiles = _FileListToArray($sFolder) ;This will pull in the name of the one profile folder. I.E. 68miioew.default DirRemove($sFolder & $aFiles[1],1) ;This will delete out the current .default folder DirCopy($sCopyFolder,$sFolder & $aFiles[1]) ;This will copy the entire .default folder to the new location EndIf Next ;This repeats the For loop DONT RUN THIS AS IS! Currently, it will replace an entire directory as that is what I thought you were doing. You can edit this basic concept to fit your needs though, as most of the code will be the same. Let me know if you have any questions. - Fett [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
teeboi Posted May 3, 2011 Author Share Posted May 3, 2011 file name is prefs.js Link to comment Share on other sites More sharing options...
teeboi Posted May 3, 2011 Author Share Posted May 3, 2011 thanks for ur help Fett 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