Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new in PowerShell scripting. I have video with my Sony RX100 but the files is big and i want to convert them. All original video and PHOTOS is stored in a structure like "c:\2013\2013-10-16 bla bla info about what's in directory\filename.MTS" (YYYY\YYYY-MM-DD INFO.MTS.

I have found script and change and i have now a script what convert a video and store it under c:\Movies. But my problem is that filename say nothing about my video.

  1. Any tip how I can i.e. rename files to "2013-10-16"+orginalname+"bla bla info about whats in directory"?

  2. I also have old films with extension .AVI. Can I make some changes to my script and convert both avi and mts videos?

    $handbrake = "C:\Program Files\Handbrake\HandBrakeCLI.exe"
    $destfolder = "C:\Movies\"
    $files = @(Get-ChildItem . *.MTS -Recurse | Where {$_ -notmatch '-AppleTV 3\.avi$'})
    foreach ($file in $files)
    $newFileName = $file.Fullname -replace '\.MTS$','-AppleTV 3.avi'
            & $handbrake -i $file.FullName -o $newFileName --preset "AppleTV 3"
            if ($LastExitCode -ne 0)
                Write-Warning "Error converting $($file.FullName)"
            write-Warning "File $($file.FullName) Previously Converted"
        Move-Item $newFileName $destfolder -force
share|improve this question
What do you mean about what's in the directory? Whats in the movie itself? Or take something like the directory name and use that as the file name? Ex C:\videos\FamilyVaction2010\video1.ext and rename as C:\FamilyVacation2010Video1.ext ? –  AthomSfere Oct 17 '13 at 0:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.