Avatar of NewsInternationalLtd
NewsInternationalLtd

asked on 

Filecopying using folder wildcards

I need to copy a 'prefs.js' file down from the netlogon share at user logon, but the folder it needs to go into would seemingly have a random name with a '.default' at the end, eg

C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\yhin11g0.default

How do I copy into this folder? It sounds such an easy problem (and maybe it is) but I've been tearing my hair out trying to do it. The usual wildcards such as * and ? only seem to work for files but not folders, eg, I am unable to use:
Copy "\\DC\NETLOGON\prefs.js" "C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\*.default\"
I have also tried this with XCOPY, ROBOCOPY and VBScript to no avail. I've probably missed something obvious but if you can put me out of my misery it would be much appreciated!

Thank you
Microsoft DOSVB ScriptWindows XP

Avatar of undefined
Last Comment
Steve Knight
Avatar of pradapkumar
pradapkumar

In the above command you are trying to copy all the .default files into a single file "prefs.js". It is not possible. To avoid that error try the following command.

Copy "\\DC\NETLOGON\." "C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\*.default"

Avatar of NewsInternationalLtd

ASKER

the *.default  is a folder though; I need to copy the file below this folder, ie

Copy "\\DC\NETLOGON\prefs.js" "C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\<*.default>\prefs.js".

Avatar of sirbounty
sirbounty
Flag of United States of America image

Try this..


for /f %%a in ('dir *.default /ad /b "%username\Application Data\Mozilla\Firefox\Profiles\"') do copy \\DC\netlogon\prefs.js "%%~dpnxa"

ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

:-)
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Thanks, glad to help.

Steve
Avatar of NewsInternationalLtd

ASKER

Sorry, just replying...
Bingo. Good work fella!
I was messing around with FOR /R for a while and getting nowhere.
I have however come accross a small issue. Although this works well when the user is logged on, the variables don't seem to be picked up during login so it fails. I may have a way around this but if you have any ideas then I'm all ears. Thanks again for your help.
Avatar of NewsInternationalLtd

ASKER

Sorry, I take that back, I was running the process administratively and it was running as a different user! Thanks again for your help!
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

No problem ... you can always use a forced path with c:\documents and settings etc. if you want to it as something other than the user..

Steve
Windows XP
Windows XP

Microsoft Windows XP is the sixth release of the NT series of operating systems, and was the first to be marketed in a variety of editions: XP Home and XP Professional, designed for business and power users. The advanced features in XP Professional are generally disabled in Home Edition, but are there and can be activated. There were two 64-bit editions, an embedded edition and a tablet edition.

119K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo