![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Change filename using a wildcard Hi. I'm trying to rename a desktop shortcut that the prefix will remain the same but the suffix changes. How can I use a wildcard when refering to a specific shortcut? Set objFSO = CreateObject("Scripting.FileSystemObject") Set oShell = CreateObject( "WScript.Shell" ) ComputerName=oShell.ExpandEnvironmentStrings("%ComputerName%") 'This is where I included the * after Shortcut to as-sysa in the filename objFSO.MoveFile "C:\Documents and Settings\All Users\Desktop\Shortcut to a2-sysa*" , "C:\Documents and Settings\All Users\Desktop\A2-SYSA " & ComputerName & ".lnk" |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Change filename using a wildcard "touch0ph" <touch0ph@xxxxxx> wrote in message news:76D67F25-85F4-4B45-AEE7-F0B8FF337195@xxxxxx Quote: > Hi. I'm trying to rename a desktop shortcut that the prefix will remain > the > same but the suffix changes. How can I use a wildcard when refering to a > specific shortcut? > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > Set oShell = CreateObject( "WScript.Shell" ) > ComputerName=oShell.ExpandEnvironmentStrings("%ComputerName%") > > 'This is where I included the * after Shortcut to as-sysa in the filename > objFSO.MoveFile "C:\Documents and Settings\All Users\Desktop\Shortcut to > a2-sysa*" , "C:\Documents and Settings\All Users\Desktop\A2-SYSA " & > ComputerName & ".lnk" seems at odds with your example where you change "Shortucut to a2-sysa*" to "as-sysaPC1.lnk" It seems you wish to do four separate things: 1. Delete all leaders called "Shortcut to " 2. Take the remaining characters up to the full stop (which you do not spell out) 3. Add the ComputerName 5. Add the string ".lnk". Would this be correct? Why don't you do it manually? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Change filename using a wildcard "touch0ph" <touch0ph@xxxxxx> wrote in message news:F6B8C066-607C-4BC5-A0C0-C2AA1114C795@xxxxxx Quote: > > > "Pegasus [MVP]" wrote: > Quote: >> >> "touch0ph" <touch0ph@xxxxxx> wrote in message >> news:76D67F25-85F4-4B45-AEE7-F0B8FF337195@xxxxxx Quote: >> > Hi. I'm trying to rename a desktop shortcut that the prefix will >> > remain >> > the >> > same but the suffix changes. How can I use a wildcard when refering to >> > a >> > specific shortcut? >> > >> > Set objFSO = CreateObject("Scripting.FileSystemObject") >> > >> > Set oShell = CreateObject( "WScript.Shell" ) >> > ComputerName=oShell.ExpandEnvironmentStrings("%ComputerName%") >> > >> > 'This is where I included the * after Shortcut to as-sysa in the >> > filename >> > objFSO.MoveFile "C:\Documents and Settings\All Users\Desktop\Shortcut >> > to >> > a2-sysa*" , "C:\Documents and Settings\All Users\Desktop\A2-SYSA " & >> > ComputerName & ".lnk" >> Your requirement "the prefix will remain the same but the suffix changes" >> seems at odds with your example where you change >> "Shortucut to a2-sysa*" >> to >> "as-sysaPC1.lnk" >> >> It seems you wish to do four separate things: >> 1. Delete all leaders called "Shortcut to " >> 2. Take the remaining characters up to the full stop (which you do not >> spell >> out) >> 3. Add the ComputerName >> 5. Add the string ".lnk". >> Would this be correct? Why don't you do it manually? >> >> > automate > it... Appending the computer name to the shorcut helps our helpdesk staff > identify the name of the PC they're on when they have remote control over > the > PC or when the PC has no label. undertaking such a task one needs to be clear about a few things: a) The complexity of the task b) How much time is required to automate the process c) Who does the work In your case the following points seem relevant: - Do you wish to process all items located on the desktop? - Including those located in the "All Users" folder? - Including those in subfolders? - Do you have some code of your own that could serve as a framework, with respondents filling the difficult details? - What do you mean with "the PC has no label"? A blank "%ComputerName%"? I thought this was impossible? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Change filename using a wildcard "Pegasus [MVP]" wrote: Quote: > > "touch0ph" <touch0ph@xxxxxx> wrote in message > news:F6B8C066-607C-4BC5-A0C0-C2AA1114C795@xxxxxx Quote: > > > > > > "Pegasus [MVP]" wrote: > > Quote: > >> > >> "touch0ph" <touch0ph@xxxxxx> wrote in message > >> news:76D67F25-85F4-4B45-AEE7-F0B8FF337195@xxxxxx > >> > Hi. I'm trying to rename a desktop shortcut that the prefix will > >> > remain > >> > the > >> > same but the suffix changes. How can I use a wildcard when refering to > >> > a > >> > specific shortcut? > >> > > >> > Set objFSO = CreateObject("Scripting.FileSystemObject") > >> > > >> > Set oShell = CreateObject( "WScript.Shell" ) > >> > ComputerName=oShell.ExpandEnvironmentStrings("%ComputerName%") > >> > > >> > 'This is where I included the * after Shortcut to as-sysa in the > >> > filename > >> > objFSO.MoveFile "C:\Documents and Settings\All Users\Desktop\Shortcut > >> > to > >> > a2-sysa*" , "C:\Documents and Settings\All Users\Desktop\A2-SYSA " & > >> > ComputerName & ".lnk" > >> > >> Your requirement "the prefix will remain the same but the suffix changes" > >> seems at odds with your example where you change > >> "Shortucut to a2-sysa*" > >> to > >> "as-sysaPC1.lnk" > >> > >> It seems you wish to do four separate things: > >> 1. Delete all leaders called "Shortcut to " > >> 2. Take the remaining characters up to the full stop (which you do not > >> spell > >> out) > >> 3. Add the ComputerName > >> 5. Add the string ".lnk". > >> Would this be correct? Why don't you do it manually? > >> > >> > > automate > > it... Appending the computer name to the shorcut helps our helpdesk staff > > identify the name of the PC they're on when they have remote control over > > the > > PC or when the PC has no label. > Indeed: Automating a process can be a great productivity tool. Before > undertaking such a task one needs to be clear about a few things: > a) The complexity of the task > b) How much time is required to automate the process > c) Who does the work > > In your case the following points seem relevant: > - Do you wish to process all items located on the desktop? > - Including those located in the "All Users" folder? > - Including those in subfolders? > - Do you have some code of your own that could serve as a framework, with > respondents filling the difficult details? > - What do you mean with "the PC has no label"? A blank "%ComputerName%"? I > thought this was impossible? > > PC's and laptops. I'm trying to cut down the time they have to spend doing mundane, repititve tasks that can be done automatically. Quote: > Do you wish to process all items located on the desktop? always start with 1 of 2 naming conventions: "Shortcut to ......" or "A2-SYSA" Including those located in the "All Users" folder? The icons are all in the "All Users\Desktop" folder. I don't need to go through all the user profiles. Do you have some code of your own that could serve as a framework, with respondents filling the difficult details? We have a naming convention that I would What do you mean with "the PC has no label"? A blank "%ComputerName%"? I thought this was impossible? A label, like a physical label on the computer chassis. What I'm asking for is a reference or example of code I could use to rename a desktop shortcut, on the All Users\Desktop, where I know the first portion of the shortcut name, but the ending is different. I figured a wildcard charcater would work best but if there's another method that would be great too! TIA! |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Change filename using a wildcard "touch0ph" <touch0ph@xxxxxx> wrote in message news:3049D6F9-2914-418B-B94F-903D6D87DCA2@xxxxxx Quote: > > > "Pegasus [MVP]" wrote: > Quote: >> >> "touch0ph" <touch0ph@xxxxxx> wrote in message >> news:F6B8C066-607C-4BC5-A0C0-C2AA1114C795@xxxxxx Quote: >> > >> > >> > "Pegasus [MVP]" wrote: >> > >> >> >> >> "touch0ph" <touch0ph@xxxxxx> wrote in message >> >> news:76D67F25-85F4-4B45-AEE7-F0B8FF337195@xxxxxx >> >> > Hi. I'm trying to rename a desktop shortcut that the prefix will >> >> > remain >> >> > the >> >> > same but the suffix changes. How can I use a wildcard when refering >> >> > to >> >> > a >> >> > specific shortcut? >> >> > >> >> > Set objFSO = CreateObject("Scripting.FileSystemObject") >> >> > >> >> > Set oShell = CreateObject( "WScript.Shell" ) >> >> > ComputerName=oShell.ExpandEnvironmentStrings("%ComputerName%") >> >> > >> >> > 'This is where I included the * after Shortcut to as-sysa in the >> >> > filename >> >> > objFSO.MoveFile "C:\Documents and Settings\All >> >> > Users\Desktop\Shortcut >> >> > to >> >> > a2-sysa*" , "C:\Documents and Settings\All Users\Desktop\A2-SYSA " & >> >> > ComputerName & ".lnk" >> >> >> >> Your requirement "the prefix will remain the same but the suffix >> >> changes" >> >> seems at odds with your example where you change >> >> "Shortucut to a2-sysa*" >> >> to >> >> "as-sysaPC1.lnk" >> >> >> >> It seems you wish to do four separate things: >> >> 1. Delete all leaders called "Shortcut to " >> >> 2. Take the remaining characters up to the full stop (which you do not >> >> spell >> >> out) >> >> 3. Add the ComputerName >> >> 5. Add the string ".lnk". >> >> Would this be correct? Why don't you do it manually? >> >> >> >> >> > Yes, you have that correct. Why do something manually when you can >> > automate >> > it... Appending the computer name to the shorcut helps our helpdesk >> > staff >> > identify the name of the PC they're on when they have remote control >> > over >> > the >> > PC or when the PC has no label. >> Indeed: Automating a process can be a great productivity tool. Before >> undertaking such a task one needs to be clear about a few things: >> a) The complexity of the task >> b) How much time is required to automate the process >> c) Who does the work >> >> In your case the following points seem relevant: >> - Do you wish to process all items located on the desktop? >> - Including those located in the "All Users" folder? >> - Including those in subfolders? >> - Do you have some code of your own that could serve as a framework, with >> respondents filling the difficult details? >> - What do you mean with "the PC has no label"? A blank "%ComputerName%"? >> I >> thought this was impossible? >> >> > desktop > PC's and laptops. I'm trying to cut down the time they have to spend > doing > mundane, repititve tasks that can be done automatically. > Quote: >> Do you wish to process all items located on the desktop? > will > always start with 1 of 2 naming conventions: "Shortcut to ......" or > "A2-SYSA" > > Including those located in the "All Users" folder? > The icons are all in the "All Users\Desktop" folder. I don't need to go > through all the user profiles. > > Do you have some code of your own that could serve as a framework, with > respondents filling the difficult details? > We have a naming convention that I would > > > What do you mean with "the PC has no label"? A blank "%ComputerName%"? I > thought this was impossible? A label, like a physical label on the > computer chassis. > > > What I'm asking for is a reference or example of code I could use to > rename > a desktop shortcut, on the All Users\Desktop, where I know the first > portion > of the shortcut name, but the ending is different. I figured a wildcard > charcater would work best but if there's another method that would be > great > too! > TIA! needs and make it robust, e.g. by doing this: - Add wildcard capability - Check if the file exists - Check if it can be renamed - Add user feedback Set oFSO = CreateObject("Scripting.FileSystemObject") Set oWshShell = CreateObject("WScript.Shell") sOldName = oWshShell.ExpandEnvironmentStrings("%AllUsersProfile%\Desktop\Shortcut to Explorer.lnk") sNewName = oWshShell.ExpandEnvironmentStrings("%AllUsersProfile%\Desktop\Explorer %ComputerName%.lnk") oFSO.MoveFile(sOldName, sNewName) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Run Exe From a CD with wildcard | VB Script | |||
| filename change | PowerShell | |||
| filename change | General Discussion | |||
| how to get the file name from using a wildcard | VB Script | |||
| Change Filename Settings for Recorded TV | Vista General | |||