'Remove white spaces in file names and change file names from lower to upper case
In Windows, I want to remove white spaces from file names and change the lower case to upper case.
file 1.txt --> FILE1.TXT
File 2.txt --> FILE2.TXT
Test 1.txt --> TEST1.TXT
I tried something like this (which is not working) on command prompt
rename "*.txt" "*.TXT" # Works
rename "file*.txt" "FILE*.TXT"
rename "Test*.txt" "TEST*.TXT"
Solution 1:[1]
As @Mofi said, cmd is not well equipped to do this. If you are on a supported Windows system, powershell was installed with it. When you are confident that the files would be renamed as you expect, remove the -WhatIf from the Rename-Item command.
Get-ChildItem -File | Rename-Item -NewName { $_.Name.ToUpper() } -WhatIf
If you are desperate to run this from a cmd prompt or batch-file, this could be used.
powershell -NoLogo -NoProfile -Command ^
Get-ChildItem -File ^| Rename-Item -NewName { $_.Name.ToUpper() } -WhatIf
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
