Jump to content

Filecopy in a changing name folder


Go to solution Solved by GuillaumeN,

Recommended Posts

Hi everyone,

I'm novice with AutoIT. I am creating a script that copy 2 files in a Firefox folder  (%APPDATA%\Mozilla\Firefox\Profiles\FOLDER), but name of this FOLDER change depending of the computeur. (For exemple: geudzg.defaut ou ytrrzedze.defaut...)

My script looks like that:

FileCopy(@ScriptDir & "\profile\places.sqlite", @AppDataDir& "\Mozilla\Firefox\Profiles\*.defaut",$FC_OVERWRITE)
FileCopy(@ScriptDir & "\profile\prefs.js", @AppDataDir& "\Mozilla\Firefox\Profiles\*.defaut",$FC_OVERWRITE)

I would like to ask to my script to copy the 2 files in this FOLDER regardless of his name. It should be better if i could copy these 2 files un all the subdirectories of "Profiles" whithever folder names.

Thank you very much for you help, and sorry if my English is clumsy.

Link to post
Share on other sites

Something like this maybe?

#include <File.au3>

Global $g_aProfiles = _FileListToArrayRec(@AppDataDir & "\Mozilla\Firefox\Profiles", "*.default", 2, 0, 0, 2)
    If @error Then MsgBox(4096, "Error", "No Profile Directories found")
For $i = 1 To $g_aProfiles[0]
    FileCopy(@ScriptDir & "\profile\places.sqllite", $g_aProfiles[$i], 1)
    FileCopy(@ScriptDir & "\profile\prefs.js", $g_aProfiles[$i], 1)
Next

 

Edited by Subz
Link to post
Share on other sites
  • Solution
25 minutes ago, Subz said:

Something like this maybe?

#include <File.au3>

Global $g_aProfiles = _FileListToArrayRec(@AppDataDir & "\Mozilla\Firefox\Profiles", "*.default", 2, 0, 0, 2)
    If @error Then MsgBox(4096, "Error", "No Profile Directories found")
For $i = 1 To $g_aProfiles[0]
    FileCopy(@ScriptDir & "\profile\places.sqllite", $g_aProfiles[$i], 1)
    FileCopy(@ScriptDir & "\profile\prefs.js", $g_aProfiles[$i], 1)
Next

 

Thank you Subz for your Help, I tried your code and have 2 errors:

 

error.jpg

error2.jpg

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...