F5F Stay Refreshed Software Operating Systems Add a Windows 11 prefix to filenames in a script.

Add a Windows 11 prefix to filenames in a script.

Add a Windows 11 prefix to filenames in a script.

1
15969
Member
143
04-06-2021, 07:00 AM
#1
Sure! Here’s a way to batch rename files with a prefix using PowerShell. You can run this script in PowerToys or directly in the command line.

```powershell
Get-ChildItem -Path "C:\Your\Folder\Path" -Recurse | ForEach-Object {
$newName = "001-Dog Walking" + $_.BaseName.Substring(0, 3) + "_" + $_.BaseName.Substring(3)
Rename-Item -Path $_.FullName -NewName $newName
}
```

Replace `C:\Your\Folder\Path` with your actual folder location. This will rename all files to start with "001-Dog Walking", "002-Dog sitting", etc., preserving the original extension. Let me know if you need adjustments!
1
15969
04-06-2021, 07:00 AM #1

Sure! Here’s a way to batch rename files with a prefix using PowerShell. You can run this script in PowerToys or directly in the command line.

```powershell
Get-ChildItem -Path "C:\Your\Folder\Path" -Recurse | ForEach-Object {
$newName = "001-Dog Walking" + $_.BaseName.Substring(0, 3) + "_" + $_.BaseName.Substring(3)
Rename-Item -Path $_.FullName -NewName $newName
}
```

Replace `C:\Your\Folder\Path` with your actual folder location. This will rename all files to start with "001-Dog Walking", "002-Dog sitting", etc., preserving the original extension. Let me know if you need adjustments!

S
SrSniper28
Member
231
04-06-2021, 08:42 AM
#2
The site bulkrenameutility could help, though it hasn’t been used much recently. For batch file handling, you’d likely follow a similar pattern to the example on Stack Overflow, using a counter to rename files. PowerShell offers comparable functionality with its own structures, while Python provides a flexible way—using os.listdir() and looping through files, then renaming them via os.rename. I’m not very comfortable with batch or PowerShell commands, but Python seems like a solid alternative.
S
SrSniper28
04-06-2021, 08:42 AM #2

The site bulkrenameutility could help, though it hasn’t been used much recently. For batch file handling, you’d likely follow a similar pattern to the example on Stack Overflow, using a counter to rename files. PowerShell offers comparable functionality with its own structures, while Python provides a flexible way—using os.listdir() and looping through files, then renaming them via os.rename. I’m not very comfortable with batch or PowerShell commands, but Python seems like a solid alternative.

J
Juan2610
Posting Freak
875
04-06-2021, 05:01 PM
#3
Script understands the task. Execute with caution on important files. The process will rename items according to the specified pattern.
J
Juan2610
04-06-2021, 05:01 PM #3

Script understands the task. Execute with caution on important files. The process will rename items according to the specified pattern.