1

I'm trying to write a batch file for copying the content of a folder with path C:\ABC to another folder whose exact name is unknown (it's a Profile data folder of Firefox)

Profiles of Firefox are created in folder %APPDATA%\Mozilla\Firefox\Profiles\ & named randomly on creation by Firefox

with the first 8 characters followed by "." & then profile name we set

For example: tx1e6sq7.ABC or 3dnwu536.XYZ

I need to find out what's the full name of folder with profile name ending with ABC, so that I can copy the content to it

P.S. I also need to delete the current contents of that profile ending with ABC, before I copy new contents. Let me know the command for that if possible

phuclv
  • 30,396
  • 15
  • 136
  • 260

2 Answers2

3

After some more searches, I solved it myself using the following commands:

set parentfolder=%APPDATA%\Mozilla\Firefox\Profiles\
for /f "tokens=*" %%a in ('"dir /b "%parentfolder%"|findstr ".*\.ABC""') do set folder=%%a

For deleting the contents, I used:

RMDIR "%APPDATA%\Mozilla\Firefox\Profiles\%folder%" /s /q
mkdir "%APPDATA%\Mozilla\Firefox\Profiles\%folder%"
Richard
  • 6,420
0

Remove the contents of the folder by following this link.

Then copy over the data with this command:
xcopy "C:\ABC\*" "%APPDATA%\Mozilla\Firefox\Profiles\*.*" /i /h /s
/i tells it it's a folder /h copies hidden files
/s copies subfolders

However, this is assuming that there is only one profile folder in the directory. If there are multiple profile folders, and you know part of the profile name that you want to copy files over to, then you can change *.* with (for example) *.ABC.

Marc05
  • 306