In my project I want add new resource file of local language. There are already some resource files in project which is distributed in many folders. Now I want such a batch file which is run in recursive for all sub folders for Finding a file which name like blabla.hi-IN.resx (eg: index.hi-IN.resx, home.hi-IN.resx etc) i.e file name which is contains 'hi-IN'. if it is exist in a folder then copy and paste it in same folder with rename blabla.mr-IN.resx (eg: index.mr-IN.resx, home.mr-IN.resx).
for-each(var folder in folders)
{
if(Exist(*G.hi-IN.resx))
{
Copy();
Paste();
rename(name);
}
}
void rename(string name)
{
remove hi-IN;
append mr-IN;
}
答案 0 :(得分:0)
Your Task can be done using my small powershell script.
This fetches all files recursively ending with hi-IN.resx
$files = gci -Filter *hi-IN.resx -Recurse
This prepares a Regex-object, which allows to remove hi-IN.resx in file name.
$reg = [regex]::new("hi-IN.resx")
This iterates over all files found in step one. For every file a copy is performed. The destination file Name is prepared using Regex-object prepared in step 2.
$files | foreach { Copy-Item $_.FullName ($r.Replace($_.FullName,"")+"mr-IN.resx") }
This is the full script:
$files = gci -Filter *hi-IN.resx -Recurse
$reg = [regex]::new("hi-IN.resx")
$files | foreach { Copy-Item $_.FullName ($r.Replace($_.FullName,"")+"mr-IN.resx") }