Tuesday, November 18, 2014

windows - Batch Renaming on a file share

We currently have a CIFS share hosted from a SAN device and are planning to move toward a case management system. The issue I'm having is a lot of the various files in our file share end with a trailing dot (.) and fail to upload.


I've been trying to get a script working that would keep file names the same but batch remove any trailing dots. I've been able to do this with variouse special characters using powershell.


We also have many sub folders that have a dot (.) in the middle of the folder name and would need to leave these alone.


Example


Original File name: 20151101 Luis K. Abrishamian M.D..pdf


New file name: 20151101 Luis K. Abrishamian M.D.pdf


I used this one to remove all & from file names


Get-ChildItem -recurse -name | ForEach-Object { Move-Item $_ $_.replace("&", "and") }

I tried this one but it failed to do what i needed


Get-ChildItem -recurse -name | ForEach-Object { Move-Item $_ $_.replace("*.", "") }

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...