I accidentally ran a bulk rename command in WSL2 which went below all window 11 folder levels and it started to rename the files to .jpg . I did ran sfc/scannow to correct for any corrupt files and it repaired any issues with Windows11 installation. Unfortunately, It left a mess in my folders and I can see the their names in CMD and I wanted to restore them to their correct names. I tried with Pictures but I got A duplicate file name exists, or the file is hidden ( there are now two Pictures folder in my User folder). Can any one help me resolve this issue?

- 101
1 Answers
Executive Summary
Use a tool that reads file signatures to restore the correct extension.
Details
Best way to restore files would be from the last disk image or backup. However, an "educated guess" for the correct file extension can be made from the file signature.
An application can examine the first and last few bytes of a file, its signature, to help determine what extension it should be given. Here are some examples:
Joint Photographic Experts Group files begin
FF D8and endFF D9, and the extension should be JPG.Portable Network Graphics files begin
89 50 4E 47 0D 0A 1A 0A, and the extension should be PNG.Zip archives begin
PK; extension should be ZIP.Windows & DOS executables begin
MZ, but the extension could be EXE, COM or other.N.B. Dynamic Link Libraries also begin begin
MZ, but the extension should be DLL.
See Kessler's list of signatures for more.
Procedure
There are existing utilities to help identify unknown file types, such as TrID. "Using the switch -ae will instruct TrID to add the guessed extensions to the filenames."
Since the signature does not always match just one extension, do not run such a file renaming application where it could mess up essential files, such as in the Windows folder, and check any changes made in Program Files and Program Files (x86), where DLL's and EXE's might be erroneously renamed.
- 37,887