Created
August 5, 2023 11:43
-
-
Save skarfie123/d05d77fd7c9375d3d5dc4ddcb72c7dbd to your computer and use it in GitHub Desktop.
add suffix to files in a folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add suffix in place | |
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer } | ForEach-Object { | |
Rename-Item $_.FullName -NewName "$($_.BaseName)-$($_.Directory.Name)$($_.Extension)" | |
} | |
# Move to parent with suffix | |
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer } | ForEach-Object { | |
Move-Item $_.FullName -Destination "$($_.Directory.Parent.FullName)\$($_.BaseName)-$($_.Directory.Name)$($_.Extension)" | |
} | |
# Copy to parent with suffix | |
Get-ChildItem -Recurse | Where-Object { !$_.PSIsContainer } | ForEach-Object { | |
Copy-Item $_.FullName -Destination "$($_.Directory.Parent.FullName)\$($_.BaseName)-$($_.Directory.Name)$($_.Extension)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment