Link to home
Start Free TrialLog in
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
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
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

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, glad to help.

Steve
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.
Sorry, I take that back, I was running the process administratively and it was running as a different user! Thanks again for your help!
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