Enviando post automatico
Cesar Romero
Sistemas
Arabela El Salvador, S.A. de C.V.
Manejo de Ficheros PowerShell
Objetivo .
- Mover todas las carpetas que contengan *.mp3 a una carpeta llamada MUSIC
-Eliminar las carpetas que esten vacias
- Crear un playlist de todas las canciones
Entorno de ejecucion PowerShell ISE
MOVIENDO CARPETAS
$Path = "J:\"
$List = get-childitem -path $Path -recurse *.mp3 | where{$_.Name -notlike "button*"}
foreach($file in $list){
$MovePath = (join-path -path 'J:\MUSIC' -childpath $file.FullName.SubString(10))
$MoveDirectory = (join-path -path 'J:\MUSIC' -childpath $file.DirectoryName.SubString(10))
new-item $MoveDirectory -type directory -ea SilentlyContinue
move-item -Path $file.FullName -destination $MovePath
}
Directorio: J:\MUSIC\2Octubre2010\COMPLETE\2008Procedo a ejecutar el ISE como Administrador
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 24/02/2011 04:57 p.m. Presentacion de Mercadeo 3er Qtr
Move-Item : Acceso denegado a la ruta de acceso.
En línea: 17 Carácter: 10
+ move-item <<<< -Path $file.FullName -destination $MovePath + CategoryInfo : PermissionDenied: (J:\22Octubre201...For Love(1).mp3:FileInfo) [Move-Item], UnauthorizedAccessException + FullyQualifiedErrorId : MoveFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.MoveItemCommand
Set-ExecutionPolicy Unrestricted
gci -Path J:\ -include *.mp3 -r | ? {$_.fullname -notmatch 'J:\\MUSIC'} | Format-Table -groupby Directorio
Mode LastWriteTime Length NameEtc
---- ------------- ------ ----
-a--- 17/02/2010 05:21 p.m. 6531072 14 Amiga [Ft. Yuridia].mp3
-a--- 01/06/2008 10:50 p.m. 13607120 Dr.Ottoniel Rios Paredes -Testimonio 1984 [17-03-84].mp3
-a--- 29/10/2009 08:27 a.m. 2766558 Una_Noche_De_Amor_-_[www.escuchamusica.com.mx].mp3
-a--- 21/08/2006 04:44 p.m. 4221056 07 Te Alaben [Salmo 67].mp3
-a--- 29/10/2009 08:38 a.m. 6469801 09 Abre Mis Ojos [Con Danilo Montero].mp3
-a--- 29/10/2009 08:39 a.m. 5894144 03 Ven Te Necesito [Lilly Goodman (Duo)].mp3
-a--- 01/05/2007 05:04 p.m. 6879232 06 Enmorame [Abel Zavala (Duo)].mp3
-a--- 15/12/2009 07:21 a.m. 3453897 Nirvana - You Know Your Right [Studio Full].mp3
-a--- 06/02/2009 09:15 a.m. 4579544 paris hilton - [paris] - nothing in this world(2).mp3
-a--- 03/08/2009 10:38 p.m. 3463714 (MeretteMusic.NeT) [MoNeGrItOxX] - Arcangel - Pa Que La Pases Bien (El Diario De Un Sonador) (MeretteMusic.NeT) [MoNeGrItOxX].mp3
-a--- 24/09/2009 05:50 p.m. 6286151 (MeretteMusic.NeT) [MoNeGrItOxX] - Tito El bambino Ft. Siklio - El Tra (Official Remix) (MeretteMusic.NeT) [MoNeGrItOxX].mp3
-a--- 03/08/2009 11:28 p.m. 2152455 Lloro Por Ti - Wisin & Yandel Ft. Enrique Iglesias [Video].mp3
-a--- 03/08/2009 11:46 p.m. 3531311 Mr[1]. Presidente - Coco Jambo.mp3
-a--- 16/12/2009 06:11 p.m. 15970383 Avicii - Dukkha (Original Mix) [www.livingelectro.com].mp3
-a--- 07/01/2010 02:33 p.m. 7399120 Chris Ortega Vs Lady Gaga - Just Dance (Dj Vartan Mash Down Mix)[www.livingelectro.com].mp3
-a--- 29/12/2009 02:02 a.m. 8688412 Ke$ha - Take It Off [www.livingelectro.com].mp3
-a--- 01/12/2009 11:40 p.m. 14186665 Pryda - Pjanoo 2k10 (South Freak Remix)[www.livingelectro.com].mp3
-a--- 23/10/2010 02:06 p.m. 6159049 08. Te Vas [Balada].mp3
-a--- 23/10/2010 02:07 p.m. 7229076 08 Ya No Queda Nada [Reggaeton].mp3
-a--- 23/10/2010 02:07 p.m. 10060404 09 Fabricando Fantasias [Balada].mp3
-a--- 23/10/2010 02:07 p.m. 5462343 10. Esa Boquita [Balada].mp3
-a--- 23/10/2010 02:07 p.m. 6407766 11. Si Yo Fuera El [Reggaeton].mp3
-a--- 23/10/2010 02:08 p.m. 4831762 09 Mi Mayor Sacrificio [Ft. Marco Antonio Solís].mp3
-a--- 18/02/2010 04:44 p.m. 3223135 arcangel - bonita [original official](2)207.mp3
-a--- 24/03/2010 01:19 a.m. 3911680 [salsa aprile 2007] calambuco - metele.mp3
-a--- 26/07/2010 04:20 a.m. 5321 04- ramsteim - bestrafe_mich[1].mp3
-a--- 26/07/2010 02:30 a.m. 4867847 06-[buck dich].mp3
-a--- 09/08/2006 08:06 a.m. 12095488 depeche mode & rammstein - personal jesus [covenant remix]175.mp3
-a--- 20/08/2010 10:03 a.m. 3186147 [Five] - Keep On Moving.mp3
-a--- 02/09/2008 11:52 p.m. 7811597 01_santana_-_black_magic_woman.mp3
-a--- 02/09/2008 11:55 p.m. 6799882 02_santana_-_oye_como_va.mp3
-a--- 02/09/2008 11:54 p.m. 6578694 03_santana_-_jingo.mp3
-a--- 02/09/2008 11:54 p.m. 9042267 04_santana_-_guajira.mp3
-a--- 02/09/2008 11:54 p.m. 5824983 05_santana_-_evil_ways.mp3
-a--- 02/09/2008 11:54 p.m. 6827852 06_santana_-_hannibal.mp3
-a--- 02/09/2008 11:51 p.m. 7059335 07_santana_-_i_love_you_much_too_much.mp3
-a--- 02/09/2008 11:54 p.m. 5254745 08_santana_-_everythings_coming_our_way.mp3
-a--- 02/09/2008 11:54 p.m. 7036647 09_santana_-_hold_on.mp3
-a--- 02/09/2008 11:54 p.m. 7605202 10_santana_-_ill_be_waiting.mp3
-a--- 02/09/2008 11:52 p.m. 8790248 11_santana_-_no_one_to_depend_on.mp3
-a--- 02/09/2008 11:54 p.m. 5701474 12_santana_-_winning.mp3
-a--- 02/09/2008 11:54 p.m. 7562548 13_santana_-_europa_earths_cry_heavens_smile.mp3
-a--- 03/11/2010 05:39 p.m. 6266355 01-luis.enrique-yo.no.se.manana.[www.CienPorCienMusic.com].mp3
Microsoft actualizo automáticamente la versión 2.0 de PowerShell.
PS J:\>$objShell = New-Object –com Shell.Application
PS J:\>$objShell | Get-Member
TypeName: System.__ComObject#{866738b9-6cf2-4de8-8767-f794ebe74f4e}
Name MemberType Definition
---- ---------- ----------
AddToRecent Method void AddToRecent (Variant, string)
BrowseForFolder Method Folder BrowseForFolder (int, string, int, Variant)
CanStartStopService Method Variant CanStartStopService (string)
CascadeWindows Method void CascadeWindows ()
ControlPanelItem Method void ControlPanelItem (string)
EjectPC Method void EjectPC ()
Explore Method void Explore (Variant)
ExplorerPolicy Method Variant ExplorerPolicy (string)
FileRun Method void FileRun ()
FindComputer Method void FindComputer ()
FindFiles Method void FindFiles ()
FindPrinter Method void FindPrinter (string, string, string)
GetSetting Method bool GetSetting (int)
GetSystemInformation Method Variant GetSystemInformation (string)
Help Method void Help ()
IsRestricted Method int IsRestricted (string, string)
IsServiceRunning Method Variant IsServiceRunning (string)
MinimizeAll Method void MinimizeAll ()
NameSpace Method Folder NameSpace (Variant)
Open Method void Open (Variant)
RefreshMenu Method void RefreshMenu ()
ServiceStart Method Variant ServiceStart (string, Variant)
ServiceStop Method Variant ServiceStop (string, Variant)
SetTime Method void SetTime ()
ShellExecute Method void ShellExecute (string, Variant, Variant, Variant, Variant)
ShowBrowserBar Method Variant ShowBrowserBar (string, Variant)
ShutdownWindows Method void ShutdownWindows ()
Suspend Method void Suspend ()
TileHorizontally Method void TileHorizontally ()
TileVertically Method void TileVertically ()
ToggleDesktop Method void ToggleDesktop ()
TrayProperties Method void TrayProperties ()
UndoMinimizeALL Method void UndoMinimizeALL ()
Windows Method IDispatch Windows ()
WindowsSecurity Method void WindowsSecurity ()
WindowSwitcher Method void WindowSwitcher ()
Application Property IDispatch Application () {get}
Parent Property IDispatch Parent () {get}
PS J:\> Get-Help Get-Member -full
Para crear los alias simplemente escribimos
# PowerShell crear alias
Clear-Host
new-alias xcopy copy-Item
# O escribiendo lo siguiente
Set-Alias xcopy copy-Item # works just as well