Powershell script, executing commands to lots of files

Following powershell script goes recursively the folder ”J:\pictures” and converts all avi file to mp4 files. It uses ffmpeg (remember to download newest binary)

I couldn’t get invoke-expression to work (it gave some error about ”-” operator), so I just sticked all the commands to a text file d:\commands.txt and run it as a normal batch script.

I used this script to convert lots of videos shot with my camera to more compatible format.

"" > d:\commands.txt
foreach ($file in get-childitem "j:\pictures" -recurse -include "*.avi"){
$ffmpegprog = "`"C:\Program Files (x86)\WinFF\ffmpeg.exe`"";
$ffmpegparams = " -threads 2 -f mp4 -vcodec libx264 -b 1500k -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 1500k -maxrate 2000k -bufsize 4M -bt 256k -refs 1 -bf 3 -coder 1 -me_method umh -me_range 16 -subq 7 -partitions +parti4x4+parti8x8+partp8x8+partb8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 256k -ac 2 -ar 44100";
$command = ($ffmpegprog + " -i `"" + $file.FullName + "`"" + $ffmpegparams + " `"" + [System.IO.Path]::ChangeExtension($file.FullName, ".mp4") + "`"");
$("$command") >> D:\commands.txt

You can just copy-paste the file to a powershell window.

For some reason direct execution of the commands.txt batch file didn’t work so you can just run it throught type

type d:\commands.txt > d:\commands.bat

USB Drive letters changing in Windows?

Try this program:


It allows user to make ntfs folder mounts automatically, similar to unix systems.

;Remove unused folder mounts
;If drive has usbdlm.ini file, use it! Otherwise assign drive letter manually
;Not that by default this works only for USB drives, add BusType definitions
;to process Firewire drives too
;If you want to hide particular devices from "safe remove" hardware dialog

Now, the usb drive should have a configuration file, usbdlm.ini, with the following contents:


Much more information is found in the program manual.

Disabling ”Open File – Security Warning dialog” in Vista (and XP SP2 onwards)

After little bit of googling I found how to remove that annoying security warning dialog (see image). This should also work in Windows XP. Here’s how to define file types ’less risky’.

  1. Run Local group policy editor by entering following command in the start menu ”gpedit.msc”
  2. Open User configuration/Administrative Templates/Windows Components/Attachment Manager and double click on the setting called ”Inclusion list for moderate risk file types”.
  3. Click ’Enabled’ and write file types you want to run without the open file security confirmation. I have ”.exe;.msi” in the text box (see image).

You could also use setting called ”Inclusion list for low risk file types”. Remember that changing either one of the settings is weakening your security! Open file security warning prevents accidental opening of email attachments, for example.

Edit: To remove confirmation dialog only from files that are opened from network drives you should consider other options (adding UNC paths to trusted sites, for example).