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
- 41
- 1
- 1
- 3
-
1Possible duplicate of [Find and rename files with no extension?](https://stackoverflow.com/questions/1025410/find-and-rename-files-with-no-extension) – Rishav Feb 26 '18 at 18:56
7 Answers
* matches any extension. You want to match no extension, so don't supply one: ren *. *.jpeg.
The above only works in 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" }
- 25,304
- 2
- 44
- 78
-
1This gave this error for me: ren : Cannot rename because item at '*.' does not exist. – EBGreen Feb 26 '18 at 14:38
-
@EBGreen: correct, that only works with cmd. The PowerShell version is more involved, see edit. (Although there may be a more elegant way.) – Jeroen Mostert Feb 26 '18 at 14:42
-
You explained very well , as earlier i was trying to run it through powershell.. by using simple cmd 'ren ......' command... & That's why it didn't worked.... Cool – Rishabh Feb 27 '18 at 19:37
"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.
- 89
- 1
- 7
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.
- 3,515
- 29
- 48
This is tested and works for me:
ls -file | ?{$_.extension -eq ''} | %{ren $_ ($_.name + '.jpeg')}
- 35,429
- 11
- 62
- 83
try this:
Get-ChildItem "c:\temp" -file "*." | rename-item -NewName {"{0}.something" -f $_.fullname}
- 15,129
- 3
- 36
- 41
-
1This is too hard to try... I just wanted a simple command...😄 if you understand, but thanks for the help – Rishabh Feb 27 '18 at 19:34
-
its a really command PowerShell, others proposition base on alias :) – Esperento57 Feb 27 '18 at 19:51
-
For me as simple as ren * *.jpeg worked.
- 721
- 1
- 6
- 21
-
-
Double-checked: renaming of 3 files with no extension in Windows cmd did the job. – Alex Feb 26 '18 at 14:41
-
1Aaah...my mistake, I assumed powershell. You are correct that it will add the .jpeg to all the files. ***All the files*** including files with an extension. – EBGreen Feb 26 '18 at 14:43
-
1
A slight variation:
dir -filter *. -file | rename-item -NewName {"$($_.name)`.jpg"}
- 80
- 1
- 6