Leap-Motion's fledgling company developed a simple, robust, and cheap device capable of accurately registering hand and finger movements. I predict this device will expand and become a de facto interface integrated into the next generation of computers, phones, and other devices which would benefit from hands-free movement-based interactions. Watch these two videos to get an understanding on how simple yet accurate the controller is and you'll agree how instrumental it'll be in future devices. I'd love to see it embedded into Google-Glass.
PS C:\Scripts>Write-host "The Best Way To Predict The Future" -foreground white
The Best Way To Predict The Future
PS C:\Scripts>"is to create it!"|for-each {write-host $_.toupper() -foreground white}
IS TO CREATE IT!
Sunday, March 10, 2013
Interfaces: New Advances
On May 13th, 2013, Leap-Motion begins selling their new computer interface which will boost Windows 8's market share. There's no surprise Microsoft envisioned a touch-based interface when designing Metro. Where Microsoft went wrong is not taking advantage of their XBOX360 Kinect product. They missed an opportunity to lead the market on gestural input designs. Instead, developers hacked the product and created their own solutions. Microsoft finally created an SDK but after the horse had bolted. Microsoft should have bundled a Kinect-like device with Windows 8 and capture this new interface market.
Leap-Motion's fledgling company developed a simple, robust, and cheap device capable of accurately registering hand and finger movements. I predict this device will expand and become a de facto interface integrated into the next generation of computers, phones, and other devices which would benefit from hands-free movement-based interactions. Watch these two videos to get an understanding on how simple yet accurate the controller is and you'll agree how instrumental it'll be in future devices. I'd love to see it embedded into Google-Glass.
Leap-Motion's fledgling company developed a simple, robust, and cheap device capable of accurately registering hand and finger movements. I predict this device will expand and become a de facto interface integrated into the next generation of computers, phones, and other devices which would benefit from hands-free movement-based interactions. Watch these two videos to get an understanding on how simple yet accurate the controller is and you'll agree how instrumental it'll be in future devices. I'd love to see it embedded into Google-Glass.
Saturday, March 2, 2013
PowerShell: Music Files, Get-Hash, and creating filtered folders
As music files are collected, it can be found that some files will have exact names even though the songs may be different versions. Another problem is getting exact duplicate songs with different file names. I created a script which filters both scenarios and moves one file-hash-based copy of exact files to a new folder structure based on the Artist name -- leaving hash duplicates in the original folders. If a second exact-named but not a hash-duplicate file attempts to move into the Artist's folder, the script makes a subfolder named after the files hash then moves the file to it.
I've only tested this script using PowerShell 3.0.
Disclaimer: This script will create new folders and move files from their original location to new ones. Script errors can result in misnamed files.
I'll explain more as we go over the script:
#Taglib is described in my previous blog
#Click here to learn how to install this ID3 tag utility
$taglib = "C:\PowerShell\taglib\libraries\taglib-sharp.dll"
[system.reflection.assembly]::loadfile($taglib)|out-null
#Select the destination root folder where you want
#your processed files to go. Make sure to leave the
#trailing backslash
$destination = "e:\hash3\"
#The hashtable variable will gather all your music files from the
#current folder and all subfolders and process their hash strings.
#Click here to learn how to install Get-Hash
$hashtable = gci -file -recurse -include *.flac,*.ape,*.ra,*.m4a,*.mp2,*.wma,*.mp3|get-hash
#We add a new Hashtable property for the incoming Artist object and
#assign an empty value "" as placeholder
$hashtable|add-member -membertype noteproperty -name Artist -value ""
#Now we select each file in the hashtable and resolve the
#artists name. If the file is not a valid music file, we
#write the error file name to the console and add it to a
#text file with other invalid files.
foreach ($a in $hashtable){
$fileperformers = $nul
$filealbumartists = $nul
$fileartist = $nul
$albumartist = $nul
#Here's the try/catch for the taglib which is trying to load
#the ID3 file values. If it finds any ID3 errors, it'll move the file to
#an "invalid Audio File"\hash-string subfolder.
try{
$media = [taglib.file]::create($a.path)
}
catch [exception]{
write-host -foregroundcolor "yellow" ($a.path + " - invalid audio file")
$a.path|out-file c:\powershell\hasherrors.txt -append
$fileartist = "Invalid Audio File"
if (!(test-path ($destination+$fileartist+"\"+$a.hash))){md ($destination+$fileartist+"\"+$a.hash+"\")}
move $a.path ($destination+$fileartist+"\"+$a.hash+"\")
}
#We pull the Artist name and filter brackets and untypical characters
$fileartist = $media.tag.performers
if ($fileartist){
$fileartist = $fileartist -replace ("\[","")
$fileartist = $fileartist -replace ("\]","")
$fileartist = $fileartist -replace ("[^0-9a-zA-Z-&\']"," ")
}
#Next we pull the Album Artist name and process it
$albumartist = $media.tag.albumartists
if ($albumartist){
$albumartist = $albumartist -replace ("\[","")
$albumartist = $albumartist -replace ("\]","")
$albumartist = $albumartist -replace ("[^0-9a-zA-Z-&\']"," ")
}
#We see if the performers tag was a real value
#if not, we try to use the album artist value
#if no performer or album artist value, we use "Unknown"
if (!$fileartist){$fileartist = $albumartist}
if (!$fileartist){$fileartist = "Unknown"}
#We enter the result into the added Artist object
$a.Artist =$fileartist
}
#We sort the resulting hash table by unique hashes
#this gives us a list of unique hashes, leaving duplicates
#behind
$hashtable = $hashtable|sort hash -unique
#We create new destination folders, check for exact file names
#in the new folders, and if exist, then create hash-named folders
#and place the file into it
#we also bypass error files which have already been moved
foreach ($h in $hashtable){
if (!(test-path $h.path)){continue}
if (!(test-path ($destination+$h.artist))){md ($destination+$h.artist)}
if ((test-path ($destination+$h.artist+"\"+$h.path.split('\')[-1]))){
md ($destination+$h.artist+"\"+$h.hash)
move $h.path ($destination+$h.artist+"\"+$h.hash)}
if (!(test-path ($destination+$h.artist+"\"+$h.path.split('\')[-1]))){move $h.path ($destination+$h.artist)}
}
I've only tested this script using PowerShell 3.0.
Disclaimer: This script will create new folders and move files from their original location to new ones. Script errors can result in misnamed files.
I'll explain more as we go over the script:
#Taglib is described in my previous blog
#Click here to learn how to install this ID3 tag utility
$taglib = "C:\PowerShell\taglib\libraries\taglib-sharp.dll"
[system.reflection.assembly]::loadfile($taglib)|out-null
#Select the destination root folder where you want
#your processed files to go. Make sure to leave the
#trailing backslash
$destination = "e:\hash3\"
#The hashtable variable will gather all your music files from the
#current folder and all subfolders and process their hash strings.
#Click here to learn how to install Get-Hash
$hashtable = gci -file -recurse -include *.flac,*.ape,*.ra,*.m4a,*.mp2,*.wma,*.mp3|get-hash
#We add a new Hashtable property for the incoming Artist object and
#assign an empty value "" as placeholder
$hashtable|add-member -membertype noteproperty -name Artist -value ""
#Now we select each file in the hashtable and resolve the
#artists name. If the file is not a valid music file, we
#write the error file name to the console and add it to a
#text file with other invalid files.
foreach ($a in $hashtable){
$fileperformers = $nul
$filealbumartists = $nul
$fileartist = $nul
$albumartist = $nul
#Here's the try/catch for the taglib which is trying to load
#the ID3 file values. If it finds any ID3 errors, it'll move the file to
#an "invalid Audio File"\hash-string subfolder.
try{
$media = [taglib.file]::create($a.path)
}
catch [exception]{
write-host -foregroundcolor "yellow" ($a.path + " - invalid audio file")
$a.path|out-file c:\powershell\hasherrors.txt -append
$fileartist = "Invalid Audio File"
if (!(test-path ($destination+$fileartist+"\"+$a.hash))){md ($destination+$fileartist+"\"+$a.hash+"\")}
move $a.path ($destination+$fileartist+"\"+$a.hash+"\")
}
#We pull the Artist name and filter brackets and untypical characters
$fileartist = $media.tag.performers
if ($fileartist){
$fileartist = $fileartist -replace ("\[","")
$fileartist = $fileartist -replace ("\]","")
$fileartist = $fileartist -replace ("[^0-9a-zA-Z-&\']"," ")
}
#Next we pull the Album Artist name and process it
$albumartist = $media.tag.albumartists
if ($albumartist){
$albumartist = $albumartist -replace ("\[","")
$albumartist = $albumartist -replace ("\]","")
$albumartist = $albumartist -replace ("[^0-9a-zA-Z-&\']"," ")
}
#We see if the performers tag was a real value
#if not, we try to use the album artist value
#if no performer or album artist value, we use "Unknown"
if (!$fileartist){$fileartist = $albumartist}
if (!$fileartist){$fileartist = "Unknown"}
#We enter the result into the added Artist object
$a.Artist =$fileartist
}
#We sort the resulting hash table by unique hashes
#this gives us a list of unique hashes, leaving duplicates
#behind
$hashtable = $hashtable|sort hash -unique
#We create new destination folders, check for exact file names
#in the new folders, and if exist, then create hash-named folders
#and place the file into it
#we also bypass error files which have already been moved
foreach ($h in $hashtable){
if (!(test-path $h.path)){continue}
if (!(test-path ($destination+$h.artist))){md ($destination+$h.artist)}
if ((test-path ($destination+$h.artist+"\"+$h.path.split('\')[-1]))){
md ($destination+$h.artist+"\"+$h.hash)
move $h.path ($destination+$h.artist+"\"+$h.hash)}
if (!(test-path ($destination+$h.artist+"\"+$h.path.split('\')[-1]))){move $h.path ($destination+$h.artist)}
}
Thursday, February 28, 2013
Facebook: Disable Notification Sound
Facebook recently implemented sounds when you receive a new notification. It's akin to the Sonic the Hedgehog game checkpoint sound. Click on the screenshot and follow the steps to disable this new sound.
Sunday, February 24, 2013
PowerShell: Get-Hash to filter file duplicates
You can find duplicate files and filter out one copy of each set into a new directory, leaving behind all the copies. This is possible thanks to the PowerShell Community Extension modules PSCX get-hash cmdlet.
(Note: I've created a more extensive script utilizing get-hash and taglib. Click here for a more comprehensive music filter technique)
1. Download the PSCX zipped folder and copy it's contents into your PowerShell modules folder ($env:psmodulepath). I used version 3.0 to run in PowerShell 3.0.
2. Import-module pscx; careful using help. I've had my shell lock up several times when asking for command help -- no matter the command. Run update-help to fix this problem.
3. Go to a populated folder and type get-hash .\*.* to ensure the module and get-hash command are working. You'll see path and hashstring objects for each file.
4. Create a destination folder for your filtered files (i.e. e:\test\hash)
5. Run the following command from the root of the folder structure you wish to examine.
getchild-item -file -recurse|get-hash|sort hashstring -unique|%{move $_.path e:\test\path}
#BTW the -file option for GCI is new for PowerShell 3.0 otherwise you'd
#have to put in the |?{!$_.psiscontainer}| section after the gci to exclude
#subfolders
You now have one copy of each file in your new filtered folder. All other copies are left in their original locations.
Obviously you can alter the command line to create subfolders, move based on various properties, etc., but basically your work is done.
If you have problems with duplicate file names when moving them to the new folder, you can have your filename duplicates create subfolders based on their hashstring, which will be unique, and be placed into them.
if ((gci -ea 0 e:\test\hash\($_.path('\')[-1]))){md -ea 0 e:\test\hash\$_.hashstring;move $_.path e:\test\hash\$_.hashstring}
(Note: I've created a more extensive script utilizing get-hash and taglib. Click here for a more comprehensive music filter technique)
1. Download the PSCX zipped folder and copy it's contents into your PowerShell modules folder ($env:psmodulepath). I used version 3.0 to run in PowerShell 3.0.
2. Import-module pscx; careful using help. I've had my shell lock up several times when asking for command help -- no matter the command. Run update-help to fix this problem.
3. Go to a populated folder and type get-hash .\*.* to ensure the module and get-hash command are working. You'll see path and hashstring objects for each file.
4. Create a destination folder for your filtered files (i.e. e:\test\hash)
5. Run the following command from the root of the folder structure you wish to examine.
getchild-item -file -recurse|get-hash|sort hashstring -unique|%{move $_.path e:\test\path}
#BTW the -file option for GCI is new for PowerShell 3.0 otherwise you'd
#have to put in the |?{!$_.psiscontainer}| section after the gci to exclude
#subfolders
You now have one copy of each file in your new filtered folder. All other copies are left in their original locations.
Obviously you can alter the command line to create subfolders, move based on various properties, etc., but basically your work is done.
If you have problems with duplicate file names when moving them to the new folder, you can have your filename duplicates create subfolders based on their hashstring, which will be unique, and be placed into them.
if ((gci -ea 0 e:\test\hash\($_.path('\')[-1]))){md -ea 0 e:\test\hash\$_.hashstring;move $_.path e:\test\hash\$_.hashstring}
PowerShell: Create contractions or input apostrophes
If you've ever needed to recreate contractions due to aprostrophe's being stripped from values or filenames, then read on:
Download my contractions.csv file (Thank you Enchanted Learning)
The contractions.csv has three columns to suit your needs. Column one is the root words used to create the contraction. Column two is the contraction without the apostrophe. Column three is the resulting contraction.
$contractions = import-csv "c:\powershell\contractions.csv" -header ("Words","NoApostrophe","Contraction")
# I've assigned $file with a file name missing an apostrophe
$file = gci "it s a gas".txt
#Now we read each row of the CSV file searching for the word combination needed
#to add an apostrophe to the name. Once found, assign a new filename variable, save the file
#with the new name and break out of the loop
Download my contractions.csv file (Thank you Enchanted Learning)
The contractions.csv has three columns to suit your needs. Column one is the root words used to create the contraction. Column two is the contraction without the apostrophe. Column three is the resulting contraction.
$contractions = import-csv "c:\powershell\contractions.csv" -header ("Words","NoApostrophe","Contraction")
# I've assigned $file with a file name missing an apostrophe
$file = gci "it s a gas".txt
#Now we read each row of the CSV file searching for the word combination needed
#to add an apostrophe to the name. Once found, assign a new filename variable, save the file
#with the new name and break out of the loop
foreach($c in $contractions){if ($file.name -like ("*" + $c.noapostroph
e + "*")){
$newfile = $file.name.replace($c.noapostrophe,$c.contraction);ren $file $newfile;break}}
#to rename a variable string value:
$songtitle = "it s a gas"
foreach($c in $contractions){if ($songtitle -like ("*" + $c.noapostrophe + "*")){$songtitle = $songtitle -replace ($c.noapostrophe,$c.contraction);break}}
Subscribe to:
Posts (Atom)
