I am trying to help an older family member sort through their files.

What I would like to do is look through all the sub directories and make separate folders with the filenames.


root > folder_01
     folder_01 may contain .mov .jpg .jpeg files

Inside folder_01 I would like to make separate folders with

root > folder_01 > mov
root > folder_01 > jpg
root > folder_01 > jpeg

the same for folder_02, folder_03 and so forth.

I know this is a complicated task for Linux terminal but maybe even a Linux or Windows program can accomplish this.

Please post if you can help with recommendation or if you need more info I will try to explain better.

Almost willing to do anything then sort through these files for days, that's why I am posting on here.

  • 1
    use mkdir -p to create folders, mv *.jpg jpg to move files; and find -type d -exec youscript.sh '{}' \; if you have many folders. – bohdan_trotsenko May 7 '17 at 16:11

This PowerShell script should do what you want (tested under Ubuntu 16.04 and Windows 10)

# Move-FileType.ps1
$Extensions = @('.mov','.jpg','.jpeg')
Get-ChildItem -Directory /root/folder_?? | ForEach-Object {
  ForEach ($Ext in $Extensions) {
    $DestPath = Join-Path $_.FullName $Ext.Trim('.')
    If (!(Test-Path $DestPath)) {mkdir $DestPath|Out-Null}
    Get-ChildItem -Path $_ -File -Filter "*$Ext" | 
      Move-Item -Destination $DestPath -WhatIf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.