Batch File: Getting usernames from C:\Users with a specific suffix
Posted on 2013-11-26
I have a directory structure on D: in WIndows Server 2008 R2 that is like this:
Where <username> is a subdirectory with a naming convention of <first initial><lastname>2013. (i.e. JSMITH2013)
I have user specific shortcuts in each users subdirectory (i.e. MyShortcut.lnk) that I would like to place in their C:\User\<username> \desktop directory
There are users in the C:\User directory that do not have the "2013" suffix that should NOT get the shortcut.
How can I accomplish this in a .Bat file?
I was thinking of something like this but it returns the whole directory and doesn't look for the 2013:
for /d %%u in (C:\Users\*) do copy "D:\MasterFiles\Users\%%u\MyShortcut.lnk" "C:\Users\%%u\Desktop"
I cant seem to find the solution.