How to prevent PowerShell -Recurse from renaming first file twice?
问题 When using powershell to rename files with their directory name and file name, my code works, except in the first file in a directory, it gives it two copies of the directory name. So the file book1.xlsx in folder folder1 should become folder1book1.xlsx but it becomes folder1folder1book1.xlsx . The remaining files in folder1 are correctly named folder1book2.xlsx , folder1book3.xlsx , etc. I have a directory, with many sub-directories. In each sub-dir are files that need their sub-dir name