Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
35 lines (25 loc) · 1.85 KB

File metadata and controls

35 lines (25 loc) · 1.85 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Powershell Compilation
1. Dives into each subfolder and appends the subfolder name to the original filename
`$Files = Get-ChildItem -Path $Dir -Recurse -File`
`ForEach ($File in $Files)
{
$FolderName = ((Split-Path -Path $File.FullName -Parent) -split '\\')[-1]
$FileName = $File.Name
Rename-Item -Path $File.FullName -NewName "${FolderName}_$FileName"
}`
2. Filters out the JPEGs and PNGs in a folder and appends the folder name to the original filename
`Get-ChildItem | Where-Object { $_.Extension -eq ".jpg" -or $_.Extension -eq ".png" -and !$_.Name.StartsWith($_.Directory.Name) } | rename-item -newname {$_.Directory.Name +" - " + $_.Name} -WhatIf`
3. Replaces all defined characters with another character in the current folder
`-literalpath` can be used to work with filenames containing special characters like square brackets "["
`get-childitem | foreach {rename-item -literalpath $_ $_.name.replace("character here","")} -WhatIf`
4. For all zip files in the current directory i'll bash the spaces in and replace em with no spaces
`get-childitem *.zip | foreach {rename-item -literalpath $_ $_.name.replace(" ","")}`
5. For all JPEG and PNG files add a prefix and suffix to their filename
`Get-ChildItem -Include *.jpg,*.png -Recurse | Rename-Item -NewName { 'Prefix' + $_.BaseName + 'Suffix' + $_.Extension } -WhatIf`
6. `Get-ChildItem | Rename-Item -NewName { 'Prefix' + $_.BaseName + 'Suffix' + $_.Extension } -WhatIf`
7. `Get-ChildItem | Rename-Item -NewName { "Prefix_" + $_.Name } -WhatIf`
8. `Get-ChildItem | Rename-Item -NewName {$_.Name + "Suffix_" + $_.Extension} -WhatIf`
9. // Change 1..X to what you want the folders to be called, e.g: `A..D`
// Change `rs` to the prefix for the folder name
// Replace `.\folderhere\` with your preferred directory
`1..X | ForEach {MD ".\folderhere\rs$_"}`
Morty Proxy This is a proxified and sanitized view of the page, visit original site.