FAQforge provides answers for frequently asked questions for the Linux-, MAC and Windows operating systems.

Remove Driver Filters to Resolve Device Manager Errors on Windows 7

Thursday, February 16, 2012 - posted by CSch

Sometimes the situation might come up where a device that was working flawlessly before will stop doing so, even if you try everything - replugging it, reinstalling its drivers, rebooting the computer - but nothing will help.

A possible cause for this is a driver filter that was either installed by any third party software or simply was corrupted. These can be part of any hardware driver and can intercept requests between software and driver (UpperFilter) or between hardware and driver (LowerFilter). Furthermore, there are two types of filter for each relation - device filters and class filters, where device filters work only for specific devices and class filters work for every device of a specific type, for example every bluetooth radio or every USB device attached to your computer. Those class drivers are the ones that usually cause the issues (if it is a filter issue) because on the software's side, it makes more sense to address those to alter specific behaviours.

If you experience such an issue (which is commonly recognized by the Device Manager errors 19, 31, 32, 37, 39 and 41) it is possible to delete class filters in the registry. Before you make any changes there, it is highly recommendable to back it up. To do so, enter the registry by entering regedit into a Run... prompt and on the left pane, right-click the topmost key (Computer). Click Export and save the file to any location. The file you just created is a .reg file and can be imported into the registry again by simply double-clicking it.

To find the correct filters in the registry, navigate to the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class key. This will have many subkeys all named like this: {36FC9E60-C465-11CF-8056-444553540000}. These represent the different classes of hardware, you can sport their type by the (Default) or Class values. The one above is for all USB devices:

Along with the other values, those keys contain the class filters if any are present. They are named UpperFilters and LowerFilters. If you have backed up your registry, look for the device giving you headaches and remove the class filters by right-clicking and deleting them.
This guide is only a solution to a possible source of errors and does not cover the whole range - if the problem persists, the source most likely lies somewhere else.

Change Drive Letter on Windows 7 to Resolve Conflicts

Wednesday, February 15, 2012 - posted by CSch

By working with different drives it sometimes may occur that two drives are given the same drive letter - usually this is not the case but it may always happen due to bugs. It is also possible that a drive loses its letter "spontaneously". What results is that one or both of them is/are not shown on Computer anymore. To resolve this error, a new letter has to be assigned to the drive with the help of the Disk Management. Right-click Computer and choose Manage. On the left pane, select Storage > Disk Management and you will see the connected drives listed in the main screen.

To change or assign a drive letter, right-click target drive and select Change Drive Letter and Paths.... On the window that pops up choose Add... or Change.... Afterwards select a new drive letter from the drop-down menu:

Remember that you choose a letter that is not already used by another drive - to ensure that, choose one on the end of the alphabet. Your computer won't have had the chance to fill all the letters up to there already. Usually it should not be possible to choose a letter that is already in use anyway, but it is good to always double-check things like these if the above error should occur.

Uninstall USB Drivers on Windows 7

Tuesday, February 14, 2012 - posted by CSch

In the time you used your current Windows 7 system you undoubtly have plugged in a lot of different USB devices into your computer, most of them never to be used on it again. You will have notices that for every different device, Windows comes up with a message telling you that it automatically installs all drivers needed to use it.

That is perfectly alright, but what if you won't use the device ever again? The drivers will remain on your hard disk in case you still need it. This is not optimal for two reasons - first: in no time, you will have a massive amount of drivers for different USB devices installed; second: drivers may be out of date the time you use your device again, even if you use it frequently.

Therefore, there is an option to uninstall or update your USB device drivers manually. Open a command prompt by searching for cmd and enter:

set devmgr_show_nonpresent_devices=1

This will set an environmental variable which can also be seen in Control Panel > System and Security > System > Advanced system settings > Environment Variables.... Afterwards, enter

devmgmt.msc

to open the device manager. This can also be done by right clicking Computer and choosing Manage, the device manager will be in the left column.

In the device manager menu, click View and enable Show hidden devices. If you now expand Universal Serial Bus controllers (USB) you will most likely have a bunch of transparent entries, which are all non present and/or hidden devices.

By right-clicking them, you can remove or upgrade their drivers if you need to. This can also be done will any other driver on the device manager and is rather useful for corrupted drivers, is to be handled with care however. If you don't precisely know if you just selected a system component for uninstallment, better don't do it.

Windows Powershell Script to Export and Import Sound Schemes

Monday, February 13, 2012 - posted by CSch

Windows 7 offers the possibility to switch between preinstalled sound schemes and also create new ones and delete those again. What it does not provide however is a way to export and import those schemes to use them on other systems. There is a way to do this but it involves copying over all the custom sound files as well as exporting and importing specific registry keys. This might be a bit too complicated for someone who just wants all their Windows systems to play some nice bird chirp at logon.

Luckily, what is possible on Windows is also scriptable in PowerShell. Therefore the following script is able to export custom sound schemes into a zipped package, including all sound files and needed registry items and also import them onto another system. All the audio files used for the custom scheme to export need to be in the C:\Windows\Media directory - on import, they are all unpacked back there and will not be found if the registry points somewhere else.

$x = "nil"

function SelectFileDialog
{
param([string]$Title,[string]$Directory,[string]$Filter="Zip archives (*.zip) |*.zip")
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$bFile = New-Object System.Windows.Forms.OpenFileDialog
$bFile.ShowHelp = $true
$bFile.Title = $Title
$bFile.InitialDirectory = $Directory
$bFile.Filter = $Filter
$Show = $bFile.ShowDialog()
If ($Show -eq "OK")
{
Return $bFile.FileName
}
Else
{
Write-Error "Cancelled by user."
}
}

function NewZip
{
param([string]$zipFilename)
$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne ".zip")
{
$zipFilename = $zipFilename + ".zip"
}
set-content $zipFilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipFilename).IsReadOnly = $false
}

function AddZip
{
param([string]$zipFilename)
$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne ".zip")
{
$zipFilename = $zipFilename + ".zip"
}$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne ".zip")
{
$zipFilename = $zipFilename + ".zip"
}
$shellApplication = new-object -com shell.Application
$zipPackage = $shellApplication.NameSpace($zipFilename)

foreach($file in $input)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
}

function ExtractZip
{
param([string]$zipFilename, [string] $destination)

if(test-path($zipFilename))
{
$shellApplication = new-object -com shell.Application
$zipPackage = $shellApplication.NameSpace($zipFilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}
}

$objshell = New-Object -ComObject Shell.Application
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”)
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)

$objform = New-Object System.Windows.Forms.Form
$objform.Text = “Export Windows 7 Sound Scheme”
$objform.Size = New-Object System.Drawing.Size(330,160)
$objform.StartPosition = “CenterScreen”

$objform.KeyPreview = $True
$objform.Add_KeyDown({if ($_.KeyCode -eq “Escape”) {$objform.Close()}})

$exportButton = New-Object System.Windows.Forms.Button
$exportButton.Location = New-Object System.Drawing.Size(20,70)
$exportButton.Size = New-Object System.Drawing.Size(75,23)
$exportButton.Text = “Export”
$exportButton.Add_Click({$x=”exp”;$objform.Close()})
$objform.Controls.Add($exportButton)

$importButton = New-Object System.Windows.Forms.Button
$importButton.Location = New-Object System.Drawing.Size(100,70)
$importButton.Size = New-Object System.Drawing.Size(75,23)
$importButton.Text = “Import”
$importButton.Add_Click({$x=”imp”; $objform.Close()})
$objform.Controls.Add($importButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Size(180,70)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = “Cancel”
$cancelButton.Add_Click({$x=”nil”;$objform.Close()})
$objform.Controls.Add($cancelButton)

$objlabel = New-Object System.Windows.Forms.Label
$objlabel.Location = New-Object System.Drawing.Size(10,20)
$objlabel.Size = New-Object System.Drawing.Size(280,40)
$objlabel.Text = “Do you want to export your current theme or import a new theme?”
$objform.Controls.Add($objlabel)

$objform.Add_Shown({$objform.Activate()})
[void] $objform.ShowDialog()

if($x -eq "nil") {exit}

if($x -eq "exp")
{
cd C:\Users\howtoforge\Desktop
$ts = (get-itemproperty (get-item HKCU:\AppEvents\Schemes).PSPath)."(default)"
$a = @()
$b = @()
newzip $ts
Get-ChildItem HKCU:\AppEvents\Schemes\Apps\ | Get-ChildItem | Get-ChildItem |
Foreach-Object {if ((get-itemproperty $_.PSPath)."(default)" -notlike "C:\Windows\Media\*\*"){($efg = ((get-itemproperty $_.PSPath).PSChildName));
if ($efg -eq $ts) { $a += ((get-itemproperty $_.PSPath)."(default)")
}}}
foreach ($i in $a){ if ($i) {$b += get-item $i}}
$b = $b | select -uniq
get-item $b | addzip $ts
reg export HKCU\AppEvents ($ts + ".reg")
get-item ($ts + ".reg") | addzip $ts
remove-item ($ts + ".reg")
}

if($x -eq "imp")
{
$p = SelectFileDialog
if ($p)
{
$ppp = (gci $p | select -expandproperty name)
$ps = $ppp.substring(0,$ppp.length-4)
extractzip $p C:\Windows\Media
regedit ("C:\Windows\Media\" + $ps + ".reg")
Start-sleep -milliseconds 10000
remove-item ("C:\Windows\Media\" + $ps + ".reg")
$p.remove
}
}

In order to be able to run the script, you need to enable running PowerShell scripts on your systems. Therefore, open a PowerShell as administrator and type in:

set-executionpolicy remotesigned

Now you can run selfmade or signed scripts. Copy and paste the script above into a notepad and find the line that was printed bold here - change my username in the path ("howtoforge") to yours. Then save it as .ps1 file.

Afterwards you can run the script by right-clicking it and running it in PowerShell or setting that as the default program to open ps1 scripts with. A prompt will pop up that will ask you if you want to ex- or import. Exporting will automatically export your current sound scheme to a zip file on your desktop (but only with the audio files lying in the said folder - exporting any schemes with files in a subfolder such as the Windows schemes will result in missing paths).

Copy the zipped package to the target system and run the script from there, choosing Import this time. Browse for the package and open it. The script will then put all the audio files to the C:\Windows\Media folder and import the registry file (a few pop ups will come up upon importing stuff into the registry, just accept them and everything should be fine).

If any issues should occur, make sure the zipped package is saved to a folder you have writing-permissions and everything for - if you changed it to something else than your desktop, this may easily happen.
If you are told that the registry file does not exist, this is because you waited too long to accept the import - after ten seconds, the .reg file is deleted to not clutter the Media folder. Just import again to solve it.

Remove Arrows From Shortcut Icons on Windows 7

Friday, February 10, 2012 - posted by CSch

Upon creating shortcuts on Windows, the icons used for them are always tagged with an additional small arrow icon to indicate that the thing you have there is only a pointer to another file, not the file itself.

If, for esthetical or other reasons, you want remove those arrow icons, you can do that by choosing a transparent icon instead of the arrow to be displayed as indicator so that it won't be visible anymore. To do that you have to apply a simple registry tweak:
Open the Windows registry by entering regedit into a Run... prompt and browse the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons

If the Shell Icons key does not exist, create it by right-clicking the Explorer key. Next, select the created Icons key and right-click the right pane to create a new String value. Name it 29 and assign the value C:\Windows\System32\shell32.dll,50 to it.
Afterwards close the registry and open a command line by searching for cmd. Enter the following commands one after another (Please note: the first one will close your explorer which means that your windows and taskbar will disappear. The last one is the command to restart your computer, which you need to do to apply all changes):

taskkill /IM explorer.exe /F
cd /d %userprofile%\AppData\Local
del IconCache.db /a
shutdown /r

After rebooting, the icons will be replaced. To revert the changes, simply remove the registry value and execute the commands again.

Undelete Deleted Files with Recuva on Windows 7

Thursday, February 9, 2012 - posted by CSch

Apart from CCleaner, Piriform has released some other useful pieces of software. Among them is Recuva, a tool to save and undelete removed data.

Files you delete are not physically removed from your hard drive until they are overwritten by new data, which makes it possible to retrieve them as long as nothing new is written on their clusters - this also includes removing data or wiping hard drives with special software such as CCleaner since they take care of deleting data properly by overwriting their hard disk space (this method is used to make deleted data inaccesible).

After checking for deleted files, make sure to go through the list for your wanted files carefully since their filenames may have changed like in the screenshot above.

You can download Recuva here: http://www.piriform.com/recuva
Like for CCleaner, there is also a portable version: http://www.piriform.com/recuva/features/portable-version

Change System Sounds on Windows 7 (Including Startup)

Tuesday, February 7, 2012 - posted by CSch

This article will deal with two aspects: handling the regular sounds which are accessible in Control Panel as well as changing the system startup sound, which is hidden inside a .dll file and quite tricky to get at.
The regular sounds can be accessed by entering the Control Panel and browsing to Control Panel\Hardware and Sound\Sounds\Change system sounds. A window with selectible sound schemes will open where you can either select a premade scheme or browse your files to choose other .wav files and save a custom scheme. The checkbox below the list already indicates that you will not find the Startup sound in it - you will need third party software for that.

The reason for this requirement is that the startup sound isn't configurable by "normal" means - it is hidden inside a .dll file, C:\Windows\System32\imageres.dll. Before you make any changes to it, make a backup-copy of it to some safe place and also one on your desktop to work with. Afterwards, download a resource hacker - these tools are used to access the data inside .dll files which can be sound files as well as icons and other things. I prefer ResEdit since it does not need an installation. You can download it here:

http://www.resedit.net/

In ResEdit, open the copy of imageres.dll you saved to your desktop.

On the left Resources column, find the "WAVE" entry - there is exactly one file in there, which has different names depending on your system language - I'm using American English, which is why it's called 5080 here (replace any occurance of that number here with the one you have for your language). To be able to import your own sound, it also must be in the .wav format and must be called the same as the file you just found.
Now delete the 5080 entry in ResEdit - right-click it and choose Remove from project. Then right-click on some empty space in the Resource column and select Add Resource... > User Definded. A window pops up - select Name identifier and type in WAVE. Now browse the sound file you want to configure as startup sound and hit Open (I don't know the maximum size of the file you can use, you might try to keep it as small as possible - it worked for me with a file size of ~90kb, others have reported more). It will have the wrong name and language defined after you import it, so you have to change that: Right-click the entry and select Rename. Leave the Ordinal identifier checked and enter 5080 into the identifier box, then select the correct language for you (Englisch (United States) if you had 5080) and hit OK. Afterwards save the file in ResEdit.

Now comes the tricky bit which is replacing the imageres.dll in your System32 folder with the one you edited. If you try to just do it, Windows will most likely hit you with the Permission-Denied-club, no matter how many administrative rights you have got. People have reported that it worked for them in save mode. A save option however is to boot off a Linux Live CD (I used Linux Mint 12 Lisa) and replace the file in the Live environment.

Therefore, just download a CD image file from here or any other Linux distribution's homepage, burn it onto a bootable CD and boot from it.

You will boot into the Live environment, from which you can test and install Linux or if you need, fix stuff on your Windows installation. I will go on with the instructions assuming you chose Linux Mint 12 from the link I provided, if you chose differently you will likely know how to accomplish the next steps on your system.
To replace the file, hover your cursor to the top left corner of the screen - an overlay will pop up. Type in terminal and open the first object of the list appearing:

This is the command line and will be needed in a few moments. Hover to the top left corner again and click on the nautilus icon on the left to open a new file manager window:

On the appearing window, have a look at the left column - there are different (or only one) drives listed, you should be able to determine your Windows system drive by its size or contents. Click on it once to show them. What is important now is the value that is shown on the window decoration on top of the window, circled in red here:

You basically need only the first few characters. Now go back to the terminal you opened and enter

sudo su -

to grant yourself administrative rights. Next, you do the copying. For that, use the following command. You can use the tab-key to autocomplete the path segments, so you don't have to write out the whole value from above. Replace my username with yours and weirdvalue with the drive's value:

cp -f /media/weirdvalue/Users/howtoforge/Desktop/imageres.dll /media/weirdvalue/Windows/System32

The file is now replaced and you can reboot, removing the CD when told to. If you encounter problems with the new imageres.dll, just repeat the process and copy the backup you made to the System32 folder instead.

Export and Import Sound Schemes on Windows 7

Friday, February 3, 2012 - posted by CSch

Importing and exporting whole sound schemes becomes handy if you want to apply your schemes to different computers or setup your system anew and don't want to copy the whole Windows theme. Doing so proves trickier as one might think though, since sound schemes are not saved as some kind of file or package as one might think.

First off, to create a custom sound scheme, head to the Control Panel and open the Hardware and Sound Options. In the Sound menu, click on Change system sounds. Leave the applied scheme as it is and instead change its components by selecting one of the listed items and browsing for a new sound file, which has to be in the .wav format. For simplicity's sake, put all your custom sound files into the C:\Windows\Media folder prior to setting them since they have to be in the exact same folder on the system you import them.

After you have applied new sounds for all the items you want to change, click the Save as... button and give your scheme a name.

Afterwards, to export the scheme open the Windows registry - do so by opening a Run... prompt (Windows + R) and entering regedit. In the left registry panel, browse for the HKEY_CURRENT_USER\AppEvents key. Right-click it and select Export to save its contents somewhere on your hard drive. Put the exported registry file and all the custom sound files you used on a USB key or another device to transfer the files.

After you have got the registry file as well as the soundfiles you used on the other system, put the sound files in the exact same folder as they were on the first system (if you followed this guide, it is C:\Windows\Media). Then double-click the registry file to add the first system's sound scheme settings to the new one (schemes are only added, non will be removed if there were custom schemes installed before). The sound scheme should now be available in the Control Panel.

Windows Powershell Script to Sort Music From Folder to Library

Thursday, February 2, 2012 - posted by CSch

The aim of the following script was to take music from a single folder with unsorted but tagged audio files and sort them into the music library according to artist and album. It often happens that you have audio files in your browser's download folder or your instant messenger's received files folder where they usually don't belong. The script should be able to move them into your music library and put them into correct folders named after the artist and the album they're on.

 

$controlssource = 1
$controlsdest = 1

$objshell = New-Object -ComObject Shell.Application
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objform = New-Object System.Windows.Forms.Form
$objform.Text = "Move Audio Data"
$objform.Size = New-Object System.Drawing.Size(300,260)
$objform.StartPosition = "CenterScreen"

$objform.KeyPreview = $True
$objform.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objform.Close()}})

$movebutton = New-Object System.Windows.Forms.Button
$movebutton.Location = New-Object System.Drawing.Size(20,170)
$movebutton.Size = New-Object System.Drawing.Size(75,23)
$movebutton.Text = "Move"
$movebutton.Add_Click({$x="move";$objform.Close()})
$objform.Controls.Add($movebutton)

$copybutton = New-Object System.Windows.Forms.Button
$copybutton.Location = New-Object System.Drawing.Size(100,170)
$copybutton.Size = New-Object System.Drawing.Size(75,23)
$copybutton.Text = "Copy"
$copybutton.Add_Click({$x="copy";$objform.Close()})
$objform.Controls.Add($copybutton)

$cancelbutton = New-Object System.Windows.Forms.Button
$cancelbutton.Location = New-Object System.Drawing.Size(180,170)
$cancelbutton.Size = New-Object System.Drawing.Size(75,23)
$cancelbutton.Text = "Cancel"
$cancelbutton.Add_Click({$a=0;$x="nil";$objform.Close()})
$objform.Controls.Add($cancelbutton)

$objlabel = New-Object System.Windows.Forms.Label
$objlabel.Location = New-Object System.Drawing.Size(10,110)
$objlabel.Size = New-Object System.Drawing.Size(280,40)
$objlabel.Text = "Please specify whether you want to copy or to move your files. Moving the files will remove them from their original directory."
$objform.Controls.Add($objlabel)

if ($controlssource -eq 1){
$objlabel2 = New-Object System.Windows.Forms.Label
$objlabel2.Location = New-Object System.Drawing.Size(10,10)
$objlabel2.Size = New-Object System.Drawing.Size(280,15)
$objlabel2.Text = "Path to file origin:"
$objform.Controls.Add($objlabel2)}

if ($controlssource -eq 1){
$objtextbox = New-Object System.Windows.Forms.TextBox
$objtextbox.Location = New-Object System.Drawing.Size(10,25)
$objtextbox.Size = New-Object System.Drawing.Size(230,20)
$objform.Controls.Add($objtextbox)}

if ($controlsdest -eq 1){
$objlabel3 = New-Object System.Windows.Forms.Label
$objlabel3.Location = New-Object System.Drawing.Size(10,50)
$objlabel3.Size = New-Object System.Drawing.Size(280,15)
$objlabel3.Text = "Path to music library:"
$objform.Controls.Add($objlabel3)}

if ($controlsdest -eq 1){
$objtextbox2 = New-Object System.Windows.Forms.TextBox
$objtextbox2.Location = New-Object System.Drawing.Size(10,65)
$objtextbox2.Size = New-Object System.Drawing.Size(230,20)
$objform.Controls.Add($objtextbox2)}

if ($controlssource -eq 1){
$browsebutton1 = New-Object System.Windows.Forms.Button
$browsebutton1.Location = New-Object System.Drawing.Size(250,24)
$browsebutton1.Size = New-Object System.Drawing.Size(26,22)
$browsebutton1.Text = "..."
$browsebutton1.Add_Click({$fold1 = $objshell.BrowseForFolder(0, "Select Folder", 0, "");$objtextbox.Text = $fold1.self.path})
$objform.Controls.Add($browsebutton1)}

if ($controlsdest -eq 1){
$browsebutton2 = New-Object System.Windows.Forms.Button
$browsebutton2.Location = New-Object System.Drawing.Size(250,64)
$browsebutton2.Size = New-Object System.Drawing.Size(26,22)
$browsebutton2.Text = "..."
$browsebutton2.Add_Click({$fold2 = $objshell.BrowseForFolder(0, "Select Folder", 0, "");$objtextbox2.Text = $fold2.self.path})
$objform.Controls.Add($browsebutton2)}

$objform.Controls.Add($copybutton)

#$objform.topmost = $True

$objform.Add_Shown({$objform.Activate()})
[void] $objform.ShowDialog()

$sFolder = $objtextbox.Text
$mFolder = $objtextbox2.Text
#$sFolder = "C:\Users\Public\Music\Sample Music"
#$mFolder = "C:\Users\howtoforge\Music"
$objfolder = $objshell.namespace($sFolder)

if ($X -eq "nil") {exit}

foreach ($strfilename in $objfolder.items())
{
for ($a ; $a -le 266; $a++)
{
if ($objfolder.getDetailsOf($objfolder.items, $a) -eq "Contributing artists")
#if ($objfolder.getDetailsOf($objfolder.items, $a) -eq "Albuminterpret")
{
$artist = $objfolder.getDetailsOf($strfilename, $a)
}
if($objfolder.getDetailsOf($objfolder.items, $a) -eq "Album")
{
$album = $objfolder.getDetailsOf($strfilename, $a)
}
}
if ($artist -and $album)
{
if (!(test-path($mFolder + "\" + $artist + "\" + $album + $strfilename)))
{
new-item($mFolder + "\" + $artist + "\" + $album) -itemtype directory
if($x -eq "copy")
{
copy-item $strfilename.Path ($mFolder + "\" + $artist + "\" + $album)
}
if($x -eq "move")
{
move-item $strfilename.Path ($mFolder + "\" + $artist + "\" + $album)
}
}
}
clear-variable artist
clear-variable album
$a=0
}

The script runs for every audio file in the specified folder that possesses both given details, here they are Contributing artists and Album (you can change it to look for different details but this does not always make sense since the script later creates the folders in the library depending on those data - there are different artist details however which can be chosen from, since not every audio file has all of them (album artist, contributing artists...). To change them, just change the single instance of them in the script. Adjust their names to the display language of your system!).

If the files have both details specified, the script goes to your library and, if not already present, creates a folder with the artist's title, a folder with the album title inside of that, and copies or moves the file to that location.

If you have fixed folders that you don't want to browse anew everytime you run the script, comment out the top two lines and the two bold lines, uncomment the two lines underneath the latter. Change the path given there to the path of your folders. You can also just uncomment one of them, just make sure to comment out the right lines when you uncomment one.

To run the script, copy and paste it into a notepad and save it as .ps1 file (select All Files from the type dropdown menu). Then right-click the file and run it with windows powershell. If it is not working, you might have to change your execution policy if you have not already done so. To accomplish that, search for powershell in the Windows menu search bar and right-click to run it as administrator. Enter

set-executionpolicy remotesigned

and run the script again. The script works finde on my Windows 7 Enterprise 64bit machine with PowerShell 1.0 installed, if some one has improvements to make I'd be glad to read.

Setting the Path Environmental Variable on Windows 7

Tuesday, January 31, 2012 - posted by CSch

Whenever you need to call executables from the command line, this is not possible unless you either have directed your console to its location with the cd (change directory) command, or have set it in the PATH variable. The Path variable is a string consisting of one or more data paths seperated by a semicolon and is used every time you call a command to enable the use of executables which are not in your current directory but in one of those you specified in the variable.
To add paths to it, right-click Computer on your desktop or your menu, hit Advanced System Settings and go to the Advanced tab. There, click on Environment Variables... and look for Path under System variables....

Edit it and add a path by placing a semicolon right after the last path and entering the complete path to the folder where your executables are placed.