I had to recover a micro-sd card using photorec. I'm left with a dir that contains lots of other dirs which also include multiple file extensions. I would like to move each file to a new dir based on the file extension:
*.jpg moved to dir /SortedDir/jpg
*.gif moved to dir /SortedDir/gif
Also needing to take into account raw files with no extension or *.<'blank>
I have done this successfully in a batch on Windows:
@Echo OFF
Set "Folder=C:\MessyDir"
Set "DestDir=C:\SortedDir"
FOR /R "%Folder%" %%# in ("*") DO (
If not exist "%DestDir%\%%~x#" (MKDIR "%DestDir%\%%~x#")
Echo [+] Moving: "%%~nx#"
Move "%%#" "%DestDir%\%%~x#\" 1>NUL
)
Pause&Exit
Looking for a linux script version.
Thanks!!