Asked by:
Mozilla Firefox file copy

Question
-
I need to copy a file from a network share to %appdata%\Mozilla\Firefox\Profiles\m3fh72ep.default location.
Since the above location will be different for all the Users, I tried creating File Preference in User Configuration with following as Destination.
%AppDataDir%\Mozilla\Firefox\Profiles\*.default\file.txt
%AppDataDir%\Mozilla\Firefox\Profiles\*\file.txt
However both did not work. I need a script which can read the Path from %appdata%\Mozilla\Firefox\profiles.ini file and then copy a file from network share to this location. Please help.
General]
StartWithLastProfile=1
[Profile0]
Name=default
IsRelative=1
Path=Profiles/m3fh72ep.default
Please help.
- Moved by Bill_Stewart Thursday, September 25, 2014 8:36 PM This is not "scripts on demand"
Thursday, August 14, 2014 10:15 PM
All replies
-
How about:
$Paths = select-string 'test.txt' -pattern 'Path=' [RegEx]$Equals = '=' $First = $Equals.Split($Paths[0])[1] # If you need to find the last one you need to go through the matches foreach ($Path in $Paths) { $Last = $Equals.Split($Path)[1] }
- Proposed as answer by PetriRiihikallio Thursday, August 14, 2014 11:31 PM
- Unproposed as answer by PetriRiihikallio Friday, August 15, 2014 12:20 AM
Thursday, August 14, 2014 11:29 PM -
You need to post your script. We will not write it for you and your request is somewhat vague.
¯\_(ツ)_/¯
Friday, August 15, 2014 12:10 AM -
Sorry, it's late over here..
The foreach loop was left over when I was playing around recognizing multiple profiles. Then you need to keep track of the [Profile\d] headings. That turned out to be too messy and you didn't ask for it, so I deleted it.
If you just need to find out the first or last Path, use this:
$Paths = select-string 'profiles.ini' -pattern '^Path=' [RegEx]$Equals = '=' $First = $Equals.Split($Paths[0])[1] $Last = $Equals.Split($Paths[-1])[1]
I also added a caret to the pattern, so it won't match any other xxxPath= (I am not familiar with Firefox ini files.)
- Proposed as answer by PetriRiihikallio Friday, August 15, 2014 12:21 AM
- Edited by PetriRiihikallio Friday, August 15, 2014 12:41 AM Simplified code
Friday, August 15, 2014 12:20 AM -
Hint:
Get-Content "$env:appdata\Mozilla\Firefox\profiles.ini" | Select-String '^path='
¯\_(ツ)_/¯
Friday, August 15, 2014 1:30 AM