我的第一篇博客分享,写这个代码的用途是在公司Ghost完系统之后去修改本地计算机名称及IP 地址,用Powershell实现. 1. 代码第一部分,检查Powershell是否已管理员权限执行,如果不是的话,强制以管理员权限开启一个powershell窗口. #region Key code: force to run with administrator rights $currentWi = [Security.Principal.WindowsIdentity]::GetCurrent()
Get-ChildItem -Path C:\temp\test -Filter *.txt | Rename-Item -NewName {$_.Basename.Replace("Old","New") + $_.extension} -WhatIf -Verbose 如上 将指定目录下的所有的文件名从 old 改成 new.. adding -WhatIf at the end of the command we are saying to PowerShe
由于国人很少有在上传图片前将图片名重命名为英语的,所以自动重命名对于WP来说尤为重要,特别是LINUX的不支持中文名的. WordPress上传多媒体的代码都存放于\wp-admin\includes\里面的file.php,打开这个文件,$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );// Move the file to the uploads dir,在