How can we rename all files in a folder having no extension at all to ".something"?
I have tried ren *.* *.jpeg
and few more but nothing working.
How can we rename all files in a folder having no extension at all to ".something"?
I have tried ren *.* *.jpeg
and few more but nothing working.
Asterisk *
matches any extension. You want to match no extension, so don't supply one. Both of the below variants will do in your case:
ren * *.jpeg
ren *. *.jpeg
NOTE: you may read here about the peculiarities of using *
and *.
with the ren
command.
The above only works in Windows Command shell (cmd). PowerShell's wildcards work differently, and mostly don't do anything special with extensions. What's more, batch renaming in PowerShell works differently. So:
dir -Filter "*." -File | ren -NewName { $_.name -replace "$", ".jpeg" }
"rename *. *.jpg" weirdly will bring up "The syntax of the command is incorrect." if there are no files without extensions in the location. I thought the command stopped working at first! So just letting people know if they have the same thing come up.
This is tested and works for me:
ls -file | ?{$_.extension -eq ''} | %{ren $_ ($_.name + '.jpeg')}
A slight variation:
dir -filter *. -file | rename-item -NewName {"$($_.name)`.jpg"}
You did everything correct but instead of *.*
you ought to use *.
as *.*
searches for all files with all extensions but the former searches for all files with no extension and that is what you want. So here is your code:
rename *. *.something
You can refer to this answer for further help.
try this:
Get-ChildItem "c:\temp" -file "*." | rename-item -NewName {"{0}.something" -f $_.fullname}
For me as simple as ren * *.jpeg
worked.