Sign in to follow this  
Followers 0
mohan93

Copying files to a folder Name which changes for every user.

9 posts in this topic

Guys,

This time am struck with the below scenario please assist.

Am copying few files to the below location using my script.

%AppData%MozillaFirefoxProfiles6zejl8ne.default

 

i need to copy files inside 6zejl8ne.default folder.
But the issue is this folder name is not constant, folder name changes for every user.

for e.g:
 

user 1 will have: %AppData%MozillaFirefoxProfiles6zejl8ne.default
user 2
will have: %AppData%MozillaFirefoxProfiles4qi4qup6.default

please assist is ther anyway i have files to the above location.

Cheers,

Share this post


Link to post
Share on other sites



jguinch,

Thanks for your reply,

The one you have mentioned about _FF_ProfilesList() doesn't fit my requirement.

_FF_ProfilesList()   - think its point to @AppDataDir & "MozillaFirefoxprofiles.ini"

but my requirement like copying the file like in below script,

FileCopy(@TempDir & "Files*.*", @AppDataDir & "MozillaFirefoxProfiles6zejl8ne.defaultextensions")

where, 6zejl8ne.default folder will change for every user.
is that we can assign that folder to constant so that i can run this script on every machine ?

Cheers,

Share this post


Link to post
Share on other sites

Used the same code,

$aProfiles = _FF_ProfilesList()
_ArrayDisplay($aProfiles)

For $i = 1 To $aProfiles[0][0]
    FileCopy(@TempDir & "Files*.*", $aProfiles[$i][1] & "extensions")
Next

 

i get error: Unknown Function name

$aProfiles = _FF_ProfilesList()
$aProfiles = ^ ERROR

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Well, you must add my _FF_ProfilesList() function in your script (with #Include <File.au3>)

#Include <File.au3>

$aProfiles = _FF_ProfilesList()
For $i = 1 To $aProfiles[0][0]
    FileCopy(@TempDir & "\Files\*.*", $aProfiles[$i][1] & "\extensions\")
Next



Func _FF_ProfilesList()
    Local $aResult[1][2] = [[0]]
    Local $sProfiles = @AppDataDir & "\Mozilla\Firefox\profiles.ini"
    Local $aSections = IniReadSectionNames($sProfiles)

    If @error OR NOT IsArray($aSections) Then Return SetError(1, 1, 0)

    For $i = 1 To $aSections[0]
        If $aSections[$i] <> "General" Then
            Local $sProfileName    = IniRead($sProfiles, $aSections[$i], "Name", "error")
            Local $bIsRelative     = IniRead($sProfiles, $aSections[$i], "IsRelative", "error")
            Local $sProfilePath    = IniRead($sProfiles, $aSections[$i], "Path", "error")

            If $bIsRelative = "error" OR $sProfilePath = "error" OR $sProfileName = "error" Then ContinueLoop

            If $bIsRelative = "1" Then $sProfilePath = _PathFull( @AppDataDir & "\Mozilla\Firefox\" & StringReplace($sProfilePath, "/", "\") )

            If NOT FileExists($sProfilePath & "\prefs.js") Then ContinueLoop
            $aResult[0][0] = UBound($aResult)
            Redim $aResult[ UBound($aResult) + 1][2]

            If IniRead($sProfiles, $aSections[$i], "Default", "error") = "1" Then $aResult[0][1] = UBound($aResult) - 1

            $aResult[UBound($aResult) - 1][0] = $sProfileName
            $aResult[UBound($aResult) - 1][1] = $sProfilePath
        EndIf
    Next

    If $aResult[0][1] = "" AND $aResult[0][0] > 0 Then $aResult[0][1] = 1

    Return $aResult

EndFunc
Edited by jguinch

Share this post


Link to post
Share on other sites

This works for me

#include <File.au3>

$search = _FileListToArray(@AppDataDir & "\Mozilla\Firefox\Profiles", "*.default", 2)
$dest = @AppDataDir & "\Mozilla\Firefox\Profiles\" & $search[1] & "\extensions\"
Msgbox(0,"", $dest)

; FileCopy(@TempDir & "\Files\*.*", $dest)
1 person likes this

Share this post


Link to post
Share on other sites

mikell

Great its working :)

Thanks for your assistance.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0