![]() ![]() ![]() Here is the command and the output from the command: In this case, the results end up being a ZZ Top song. Get-ChildItem -Path E:\music -Filter *.mp3 -Recurse | select -Last 1 | Format-List *Īs you can see from the following output, the –Last 1 parameter selects the last file and only one file. Here is the command I use to grab a single file and send the output to the Format-List cmdlet: To do this, I take one file and send it to the Format-List cmdlet so I can see what the sample data would be. Now I need to figure out what properties I am interested in recording. I have succeeded in finding all of my MP3 files. The command and the output from the command are shown here: I am not worried about that, because I know that I am going to eventually feed the data to a CSV file. The command spits out a lot of stuff in the Windows PowerShell console window. Get-ChildItem -Path E:\music -Filter *.mp3 –Recurse Here is the command to perform a recursive lookup of all the MP3 files in all the folders in the Music folder: The following image illustrates my directory structure: I also know that all of my music files are MP3 files, so I can use the Get-ChildItem cmdlet to find all of my files. It is not too difficult of a task, because I have a folder named Music that is on my E:\ drive (a 1 TB hybrid expansion drive). The first thing I need to do is to find my music files. You should read the first post, List Files in Folders and Subfolders with PowerShell. Note This is the second in a series of posts that talk about working with files and folders by using Windows PowerShell. Anyway, GB, the solution to your issue is rather simple because Windows PowerShell contains a built-in Export-CSV cmdlet. What does the fox say? keeps wafting across the room from the Scripting Wife’s Surface. But it is not quiet around here for another reason. ![]() This morning I am sipping a nice cup of Darjeeling tea with a cinnamon stick in it, and checking my email at I thought it would be a nice quiet morning because I finished teaching my Windows PowerShell for Writers class last week. Microsoft Scripting Guy, Ed Wilson, is here. Is there an easy way to do this by using Windows PowerShell? I would like to be able to look at the file information in Microsoft Excel so that I can find, for example, the largest files, or sort them by directory name. Hey, Scripting Guy! I have a lot of music files that reside in nested folders. Summary: Microsoft Scripting Guy, Ed Wilson, talks about exporting a directory list to a CSV file and opening the file in Microsoft Excel with Windows PowerShell. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |