Wildcards

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
engima8559
Posts: 4
Joined: 11 Sep 2012 14:01

Wildcards

#1 Post by engima8559 » 11 Sep 2012 14:19

hey all, I am new to the forum and fairly new to batch as well. I came across this post that ALMOST answered my questions:

viewtopic.php?f=3&t=2619&p=11995#p11995

the only problem as that I had two folders that need a wildcard. The above showed for a path with 1 wildcard.

I have tried working off of the working code in the link but am lost when trying to set another array for the second wildcard.

The path I am having issues with is: C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\zu97pxta.default

I am trying to save off the pref.js from the mozilla firefox 15.0.1 install to another location and then copy over the preconfigured prefs.js that I need.

I am trying to do this for all of the users that have a profile on the system since mozilla is profile specific, hence those two folders that need a wildcard.

Any help would be greatly appreciated!

thanks!
Last edited by engima8559 on 12 Sep 2012 08:54, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Wildcards

#2 Post by foxidrive » 11 Sep 2012 19:05

engima8559 wrote:I am trying to save off the pref.js from the mozilla firefox 15.0.1 install to another location and then copy over the preconfigured prefs.js that I need.


Is that all you need to do?

engima8559
Posts: 4
Joined: 11 Sep 2012 14:01

Re: Wildcards

#3 Post by engima8559 » 12 Sep 2012 08:52

foxidrive wrote:
engima8559 wrote:I am trying to save off the pref.js from the mozilla firefox 15.0.1 install to another location and then copy over the preconfigured prefs.js that I need.


Is that all you need to do?


Thanks for the response. Yes, I have the install, error checking, exit routines all working. I just need to incorporate this move and subsequent replace for the prefs.js. All will done on the box locally, no shares involved.

Thanks!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Wildcards

#4 Post by foxidrive » 12 Sep 2012 09:29

This should do it (untested)

Code: Select all

@echo off
set "folder=C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles"
set "target=c:\backup"
set "prefs="c:\folder\prefs.js"

for /f "delims=" %%a in ('dir "%folder%" /a-d /b') do (
if exist "%folder%\%%a\prefs.js" copy /y "%folder%\%%a\prefs.js"  "%target%\%%a-prefs.js" >nul
copy /y "%prefs%" "%folder%\%%a" >nul
)

engima8559
Posts: 4
Joined: 11 Sep 2012 14:01

Re: Wildcards

#5 Post by engima8559 » 12 Sep 2012 10:49

Thanks but the pathing is not found. The prefs.js in the firefox install is located in each user's profile area:

C:\Users\UserName\AppData\Roaming\Mozilla\Firefox\Profiles\zu97pxta.default\prefs.js"

The areas bolded are going to be different for every user and I do not know the usernames of the users. Those two bolded folders need to be wildcarded.

thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Wildcards

#6 Post by foxidrive » 13 Sep 2012 04:10

Ahh, yes. I see.

Can you run it on a login script? That can work with a simple adjustment to the script above.

engima8559
Posts: 4
Joined: 11 Sep 2012 14:01

Re: Wildcards

#7 Post by engima8559 » 18 Sep 2012 10:44

Hi,

It is going into a package wrapped up for remote deployment (third party product) at their disposal when and as needed so logon script is out

thanks

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Wildcards

#8 Post by abc0502 » 18 Sep 2012 11:19

Hi, to get the current user name you just put %userprofile%

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Wildcards

#9 Post by foxidrive » 18 Sep 2012 12:23

Try this:

Code: Select all

@echo off
set "target=c:\backup"
set "prefs="c:\folder\prefs.js"
md "%target%" 2>nul

for /f "delims=" %%a in ('dir "%systemdrive%\users" /b') do (
for /f "delims=" %%b in ('dir "%systemdrive%\users\%%a\AppData\Roaming\Mozilla\Firefox\Profiles" /b 2^>nul') do (
echo user "%%a" profile "%%b"
if exist "%systemdrive%\users\%%a\AppData\Roaming\Mozilla\Firefox\Profiles\%%b\prefs.js" copy /b /y "%systemdrive%\users\%%a\AppData\Roaming\Mozilla\Firefox\Profiles\%%b\prefs.js"  "%target%\%%a-%%b-prefs.js" >nul
copy /y "%prefs%" "%systemdrive%\users\%%a\AppData\Roaming\Mozilla\Firefox\Profiles\%%b\" >nul
)
)
pause

Post Reply