Wednesday, March 7, 2018

running batch file within powershell

I'm running a batch file within PowerShell. It calls up another program to do a bunch of maps which it outputs to a subfolder called "GRD"


I then want to rename the files in the GRD folder by adding spaces " " where there are underscores "_", so I'm using the PoweShell command:



DIR | Rename-Item -NewName { $.name -replace ""," " }



This line works fine if I type it into the PS command window after I've run my batch file. But is there a way that I could incorporate this line into the end of my batch file? I've tried:



cd GRD


DIR | Rename-Item -NewName { $.name -replace ""," " }



But i get the error:



C:\Data\GRD>DIR | Rename-Item -NewName { $.name -replace ""," " }


'Rename-Item' is not recognized as an internal or external command, operable program or batch file.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...