'Is there a way to Alias a dead network path to a local directory in Windows 7?
I have a bunch of old Batch scripts that I may need to revive that have hundreds of references to a dead specific network path. Is there a way to alias \\myNetWorkPath.com\SomeFolder\SomeFolder2 to a specific local Windows 7 directory?
For example, \\myNetWorkPath.com\SomeFolder\SomeFolder2 alias to C:\SomeFolder2.
Again, \\myNetWorkPath.com\SomeFolder\SomeFolder2 is a dead (not working anymore) network path.
Please let me know if that doesn’t make any sense. Thanks!
Solution 1:[1]
Following up on my "Pick a language and write a quick and dirty application that will change your code base." comment... Here's a bit of c# that could get your going.
static void Main(string[] args)
{
//foreach file you drop onto the compiled EXE
foreach (string item in args)
{
if (System.IO.File.Exists(item))//if the file path actually exists
{
ChangeThePath(item);
}
}
}
private static void ChangeThePath(string incomingFilePath)
{
string backupCopy = incomingFilePath + ".bck";
System.IO.File.Copy(incomingFilePath, backupCopy);//make a backup
string newPath = "c:\\This\\New\\Path\\Is\\Much\\Better";
string oldPath = "c:\\Than\\This\\Deprecated\\One";
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(incomingFilePath))
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(backupCopy))
{
string currentLine = string.Empty;
while ((currentLine = sr.ReadLine()) != null)
{
sw.WriteLine(currentLine.Replace(oldPath, newPath));
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | blaze_125 |
