Find & Move files based on csv headers

Hi Everyone,
Basically, I am trying to find locations for those files listed in a csv file. Content of the csv file is shown below:
Name,
filename1.xlsx,
filename2.xlsx,
filename3.xlsx,
And this is my code but I couldn't get it to work!!
$csv=import-csv c:\input.csv
Get-ChildItem -Recurse | Select-Object name, PSPath | where {$_.name -match $cvs.name} | Export-csv c:\output.csv
This code will find files if I replace $cvs.name with a string, I am not very at scripting and hoping anyone who is experienced in PowerShell could provide some advices! Any opinion is appreciated!! Thank you!!

Try this:
$csv = (Import-Csv "c:\input.csv").name
Get-ChildItem -Path ".\*" -Recurse -Force -File -Include $csv |
Select-Object Name, FullName |
Export-csv "c:\output.csv" -NoTypeInformation
Changed items from posted code:
Quoted file path in Import-Csv and Export-Csv statements - best practice
Selected .name property at the $csv assignment line
Use additional paramters in the Get-ChilItem cmdlet to filter on the file names in the $csv variable
Picked FullName instead of PSPath in the Select statement
Variable name was misspelled in the Where statement, but the entire statement has been removed
Removed Type Information from Export-Csv statement
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

Similar Messages

  • How to find movie file from external hard drive in imovie?

    i shot 29 gig of video on the road. i imported it into my macbook to the desktop. then i drag and dropped it into an external hard drive. now i have since dragged and dropped the file to my imac at home to work with it in imovie, but imovie cannot find any mpeg or any such movie file. i then tried to put it back to the canon hg10. after i plugged in the canon, i dragged the movie folder to the canon and it imported 29 gig. but the canon does not show any new movie files in the video mode. when i open import options in imovie, no new movies appear. any ideas?

    For iMovie to see your file, it must be either on the internal drive, or it can also be on an external drive that is formatted as Mac OSX Extended (Journaled). (Not FAT32).
    For the internal drive, your clips must be stored in a folder inside the Movies/iMovie Events/ folder.
    For the external drive, your clips must be stored in a folder within the iMovie Events folder at the top level of the drive. Move your files there and then start iMovie, and it should see them.
    Message was edited by: AppleMan1958

  • IMovie Can't Find Movie File Location

    I had to reinstall the OS and all software on my MacBook Pro and after I imported the Movie files back into iPhoto, iMovie can no longer find the movie files for the projects. When I open an iMovie project, there is a yellow triangle with an exclamation point in it. How can I tweak the iMovie project file to point to the movies in the new location?

    It is not the easiest thing to do, but it is possible.
    Please make a backup copy of the project file before attempting brain surgery.
    An imovie project file (with extension .rcproject) is a package. Right click on your Project file in the Movies/iMovie Projects folder. Select Show Package Contents.
    There should be a text file in there called Project.
    It will be in hexadecimal, so you need a hex-capable text editor to read it.
    I would suggest BBEdit (best but $$$) or PListEditPro (free from Apple).
    In this file, you may be able to see the paths and filenames for the clips used in the project.
    This is where iMovie expects to find the clips.
    The least risky thing to do is to move them to where iMovie thinks they should be, with the right names. However, this may impact iPhoto if you are changing the iPhoto library without telling iPHoto.
    So, alternatively, you could edit the file with the new paths and or file names.

  • Finding movie files

    The finder says I have 25 gigs of movie files. When I serch for .mov or .avi, I get just a mb's of files. How do I find the rest?

    The mpg files should also be in iPhoto, and iMovie should be able to find them there.
    If you open iMovie, it may ask you to allow it to generate thumbnails for iPhoto events. If so, say yes and give it some time.
    There should be an Event in the Event Library called iPhoto Events, where you should be able to find all the videos from your still camera.

  • Finding .mov files in spotlight

    I load my .mov files from my canon camera to iPhoto.  I have a hard time searching for these videos when I go back and try to find them.  I don't always remember the date to go look in iphoto for when the video was taken.  If I want to pull up all .MOV files how do I do that?  I tried spotlight and it doesn't display my .MOV files for some reason.  Any help would be much appreciated!  Thank you!

    You may want to try creating a smart folder with all your computers .MOV files in it that way you will always have them in one place.
    To create a smart folder:
    Mountain Lion:  http://support.apple.com/kb/PH11021
    Lion:                http://support.apple.com/kb/PH4158

  • Logic is unable to find movie file

    I have tried "everything", but Logic won't load my score. I imported a movie file from FCP and since it was a reference movie, the render files are gone (I've edited the film in FCP since). Now in Logic, it is trying to find those render files...they're gone. So how do I get around this. How do I tell Logic to forget that video file so I can import the new one? This is a ridiculous issue! Thanks for your help.

    Pixelkid wrote:
    I have tried "everything", but Logic won't load my score. I imported a movie file from FCP and since it was a reference movie, the render files are gone (I've edited the film in FCP since). Now in Logic, it is trying to find those render files...they're gone. So how do I get around this. How do I tell Logic to forget that video file so I can import the new one? This is a ridiculous issue! Thanks for your help.
    Sorry to break the news to ya, but it's not an issue or even a ridiculous one. You deleted the files, so it's down to pilot error. Now, here are a few things you can do to remedy the situation...
    *Suggestion 1* -- create a dummy movie. Length, content, doesn't matter. Give that movie exactly the same name as the original and put it in exactly the same location as where the original movie lived. Then try and load your session. Logic's not going to know the difference between the original file and that one, so it should load.
    *Suggestion 2* -- launch Logic and hold down the CNTRL key while it launches. You'll get a message asking if you want to run CoreAudio. Say "no". Then try and load your file.
    Or... if you have Logic up and running already, turn off CoreAudio in your prefs. Then try and load the file. Once it's loaded up, delete the movie from within Logic.
    *Suggestion 3* -- find a copy of the original files in your backups. Restore them to their original location, including the proxy (reference) movie file.

  • Is it possible to find movie files in your quicktime cache

    when I had a pc years ago, I was able to find vieo files in my cache, is that possible, say for instance I view a quicktime file online, will that file be in my quicktime cache?..and if so, how do I acces it....without having to go back to the site?

    QuickTime Player has a "recently viewed" list (if the link was opened by the Player and not the browser plug-in).
    New to QuickTime 7 is a browser caching option that lets each user set the "size" of this cache. Sys Prefs/QuickTime/Browser and set the size.
    You can then "Favorite" those same cached files and view them "offline".

  • Is it a bug -- can't find movie file data "expo-3" ???

    I am having a problem with the new iLife 06 suite though I believe this relates back to Tiger. After installation, I launched Garageband and received the below message. The same thing happens while opening a QT-file with FCE. Both applications are telling me that
    "the movie-file data "expo-3" cannot be found, without this file the app cannot play properly"
    I really don't know where this came from, but it appeared after the installation. Repaired permissions and restarted but still maintaining this problem. Any idea?
    H

    I am assuming that this may be fixed in the next upgrade, right?!

  • Where can I find movie files in iDVD?

    Hello,
    So, I have lost a quicktime movie file that I made in iMovie and cannot locate the file anywhere on my HD. However, when I open the iDVD Project (iDVD 7.1.2) I made to make a DVD the movie plays fine inside of the project. Does this mean the movie file still exists on my Hard Drive somewhere? Is there any way to access the file? I have looked in the Movies Library in iDVD and it is not there! Thoughts?
    Thanks,
    John

    It will be located inside the iDVD project package under
    However, they will not have any of the audio associated with the video.  And the extension will have to be changed to .mov but again with no sound.
    For future projects is you save the project as an archived project file
    all of the media files, photo, video, etc., that are used in the project will be copied into the project file in the Assets folder:
    OT

  • Archive/Move files based on Modified Date range to another Library Using PowerShell while retaining Metadata

    Hi,
    I am trying to archive files from a SharePoint 2010 document library by moving them to another library that's a dedicated archive/folder/library. The files to be moved are selected based on their modified date column value that should range between any time
    in the past to January 1st 2012. 
    Also, to be able to retain the tags and cloumn values after the move. Open in explorer does not bring along the user added tags.
    I tried to edit this script
    $WebURL = "http://mysite.com/";
    $ListDisplayName = "Crawl Test Library";
    $ArchiveFolderName = "Crawl Test Library Archive";
    function moveItems ()
    trap
    #make sure we dispose of these in the event of an error to avoid memory leaks:
    write-host "Error - disposing of objects...";
    $Web.Dispose();
    $Site.Dispose();
    [Microsoft.SharePoint.SPSite] $Site = New-Object Microsoft.SharePoint.SPSite($WebURL);
    [Microsoft.SharePoint.SPWeb] $Web = $Site.OpenWeb();
    [Microsoft.SharePoint.SPList] $List = $Web.Lists[$ListDisplayName];
    $FolderToMoveTo = $List.RootFolder.Url + "/" + $FolderName;
    $ItemMoveCount=0;
    $Query = New-Object Microsoft.SharePoint.SPQuery;
    $Query.Folder = $list.RootFolder;
    $camlQuery = "<Where><Leq><FieldRef Name='Modified' /><Value Type='DateTime'>2012-01-01T00:00:00Z</Value></Leq></Where>"
    $Query.Query = $camlQuery
    $Query.RowLimit = 2200; #limit query because of large folder
    $List.GetItems($Query) |
    Where {$_.ContentType.Name -ne "Folder"} |
    foreach-object {
    #Line below will simply output to console and demonstrates another .NET call
    [System.String]::format("Moving Item {0} with ID {1}...",$_.Name, $_.ID.ToString());
    $Web.GetFile($_.Url).MoveTo([System.String]::format("{0}/{1}",$FolderToMoveTo,$_.Name));
    write-host "Success...";
    $ItemMoveCount++;
    write-host "==============================================================================";
    write-host "Complete! -> Moved " $ItemMoveCount " Items to directory " $FolderName;
    write-host "==============================================================================";
    #dispose:
    $Web.Dispose();
    $Site.Dispose();
    #garbage collection
    [GC]::Collect()
    to do that but it doesn't seem to work. I am no guru in powershell yet so any help is appreciated.
    Thanks.

    This solution gets the job done. Much thanks to
    Ian Hayse
    NB...The Modified and Created dates are gonna reflect runtime dates now 
    $web = Get-SPWeb "http://sharepointed.com/"
    $list = $web.Lists["Shared Documents"]
    $spQuery = New-Object Microsoft.SharePoint.SPQuery
    $spQuery.ViewAttributes = "Scope='Recursive'";
    $spQuery.RowLimit = 2000
    $caml = '<Where><Lt><FieldRef Name="Created" /><Value IncludeTimeValue="TRUE" Type="DateTime">2014-01-01T04:06:45Z</Value></Lt></Where> '
    $spQuery.Query = $caml
    do
    $listItems = $list.GetItems($spQuery)
    $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
    $listTotal = $listItems.Count
    for ($x=$listTotal-1;$x -ge 0; $x--)
    try
    $listItems[$x].CopyTo("http://sharepoint/Docs/Documents/"+ $listItems[$x].name)
    Write-Host("DELETED: " + $listItems[$x].name)
    $listItems[$x].Recycle()
    catch
    Write-Host $_.Exception.ToString()
    while ($spQuery.ListItemCollectionPosition -ne $null)

  • Can't find movie files that are eating up my memory

    I have a MacBook Pro (Retina, 13 inch, Late 2012) and last week I kept getting notifications that my memory was almost full so I checked out "Storage" under "About this Mac" and it showed that about 120 GB were being taken up by movies. I removed all the videos from my Mac and removed all my files from iPhoto, adjusted search criteria in Finder for movies, and emptied the trash and restarted my computer several times. Now it shows that I have 113 GB of movies and I can't find out where these alleged files are. Any suggestions on how to deal with this? Do I need to reformat my computer?

    Seven ways to free up drive space
    Where did my  Disk Space  go?
    Slimming your hard drive
    OmniDiskSweeper is a free utility that checks HD space.
    FreeSpacecost $1 or is a free utility that checks HD space.
    SpaceControlis a free utility that checks HD space.
    FreeSpacecost $.99 - FreeSpace shows you how much space is available on all local, connected, and network drives with a single click.

  • I was wondering if it was possible to use Automator to move files based on the filename.

    Hi,
    I'm kind of new to Automator and I'm trying to come up with a sequence that will severely save me a few hours a day moving files from two larger folders into smaller folders. Basically the setup is that I have two folders, one constantly being populated with images and the other with video files. They each have file names starting with a two digit number (i.e. 12, 11, 10...) or "BG" and then a two digit number (i.e. BG12, BG11, BG10...) with the digits corresponding to a year. Essentially, I'd need to move the files into folders corresponding to the year (i.e. files starting with BG12 and 12 would be moved to 2012, files starting with BG11 and 11 would be moved to 2011, etc). As it stands now, I've only been able to get the 2012 folder populated. Any help would be greatly appreciated. Thanks.

    Hi,
    Here's a solution that uses a script, because it is not possible, at least to make twenty or more Workflows
    In Automator :
    Create a new worflow.
    Add the action "Run Shell Script", select "/bin/bash" in the popup menu
    Cut the text in the action.
    Copy/paste this script in the action :
    targetsDir=('/Users/jack/Desktop/MyImagesFolder' '/Users/jack/Desktop/MyVideosFolder')
    destDir=('/Users/jack/Desktop/yearImageFolder' '/Users/jack/Desktop/yearVideoFolder')
    for i in 0 1;do
          subfolder="${destDir[$i]}"/20
          for each in "${targetsDir[$i]}"/*;do
                if [ ! -d "$each" ];then ## not a directory
                      name=${each##*/};
                      if [[ $name =~ ^([0-9]{2})|^..([0-9]{2}) ]]; then
                            [[ $name =~ ([0-9]{2}) ]] && year=${BASH_REMATCH[1]};
                            /bin/mv -n "$each" "$subfolder$year"
                      fi
                fi
          done
    done
    Replace the paths in the first line by the path of your Images Folder  and Video Folder, use drag/drop between the simple quote ''
    Replace the paths in the second line by the path of your destibation Folders, use drag/drop between the simple quote ''.
    This script will not overwrite existing files, If you want to replace the existing file, use the /bin/mv -f instead of /bin/mv -n
    That's it.

  • Can't find movie files

    I have two questions that I need help with:
    1) I've read some posts that say my iTunes movies should be in: Username > Music > iTunes > iTunes Media > Movies. But when I follow that thread, there isn't a folder named "iTunes Media". Would it be someplace else?
    2) I created a folder called "Movies" in: Username > Movies. I store all my m4v movies there that I watch on iTunes. If I were to save this folder to an external HD and delete the folder on my Macbook, would the movies still show up in iTunes?

    Seven ways to free up drive space
    Where did my  Disk Space  go?
    Slimming your hard drive
    OmniDiskSweeper is a free utility that checks HD space.
    FreeSpacecost $1 or is a free utility that checks HD space.
    SpaceControlis a free utility that checks HD space.
    FreeSpacecost $.99 - FreeSpace shows you how much space is available on all local, connected, and network drives with a single click.

  • How do I automatically position my files based on the Media Start time?

    In the project media window, it shows the Media Start, End, Duration of my MOV files based on the timestamp in the file.
    I'm talking about the time at which the video was shot (according to the camera), not any marks I have added.  Note the distinction: all searches for this treat "Media Start" as the mark-in, mark-out points and have nothing to do with what I'm asking.
    There are gaps between the files so I don't want to add them contiguously.  I will be lining this up with other sources, and using the absolute time is the easiest way to "just do it", within a fraction of a second.
    (I have not used Premiere since version 1.5 Pro)

    I'll try that Sync command on the next one; thanks.
    At least I should be able to get this out faster than last year's New Year videos: the lighting was so bad that I had to learn color correction and the Resolve tool to accomplish it.
    I've used (if memory serves)
    Ulead Mediastudio Pro
    Premere Pro 1.5 circa 2005 
    hiatus early 2008 (last use of DV camcorder) — Feb 2013 (dSLR video)
    Avidemux (just trimming and concatenating)
    Sony Movie Studio Platnum 12, 13 (when I needed real NLE again)
    DaVinci Resolve (color correction, but hey includes basic NLE and free!)
    Adobe CC 2014 includes Premiere, so jump to that!
    I learned concepts like importing asset files to a media pool and then taking clips from that, multi-track timeline editing with razor, single and all-track ripple, rolling edit, crossfades, J and L cutting, and all that, from Ulead in 2002 and later Premere.
    Other NLEs I've used since, sometimes one-off, I had no trouble doing basic things.  It's like driving a car: basic essential functions are known but need to hunt around for the interval wipers.
    This one, though, took much longer to get moving with.  They purposefully changed some control concepts presumably for the better (where is the toggle to slide all clips beyond this one when I move it, and another toggle for keeping all tracks in sync or just editing one?   I clicked somewhere to expand the track vertically but I can't quite figure out where to do it reliably.
    But also made things unnecessarily difficult: it says drop stuff here to to start, but why not allow right-click to work and show useful things in this situation, or at least have a "new" button!  There's no speed slider or reverse buttons in the player interfaces, and in general there are commands I can't find on any menu but apparently exist.
    The scrollbar/zoom will take getting used to, but why can't the arrow buttons still be there too?  Especially at high zoom the slider is much too touchy, and clicking to move a little bit would be helpful.  Ctrl-Wheel doesn't work in the waveform source editor but does on the timeline.

  • Move Files By FileName

    I have a load of files that are desposited on my user desktop via ftp.  Each of these files begins with the same six letters.  It is a pain to select all of the files manually and then pull them into a folder.  I have looked extensively and have tried unsuccessfully to create an applescript that will accomplish the following action:
    Take the files with fileNames containing "XXXXX" (or beginning with "XXXXX") at "mac HD:user:me" and move them to the folder "XXXXX" at "mac HD:user:me."
    These files all end with the same extension, so I could also delimit the files to be moved by using their extension, if that is a better solution.
    Lastly, it would be great if I could also set the above action to occur automatically at some interval.
    I can't imagine that prescribing the above sort of action is difficult via applescript, but I must admit that a solution eludes me.  If someone happens to have a script that accomplishes this sort of action that they might share, please let me know.
    Thanks

    Twtwtw is right: there should never be a colon in any file name!
    I've put four JPEG files on my desktop, sequentially named “XXXX# - 20130410s132159265.jpg”,  “XXXX# - 20130410s132159266.jpg”,  “XXXX# - 20130410s132159267.jpg” and  “XXXX# - 20130410s132159268.jpg” (but without any colon in their names). Then I created a folder named “XXXX” in my home folder. Then I run the following script:
    set theDestinationFolder to POSIX file "/users/pierre/XXXX" as alias
    tell application "Finder"
              move (files of desktop whose name begins with "XXXX") to theDestinationFolder
    end tell
    The four files were properly moved to the destination folder, while the following result was displayed in the AppleScript Editor Result panel:
    {document file "XXXX# - 20130410s132159265.jpg" of folder "XXXX" of folder "pierre" of folder "Users" of startup disk of application "Finder", document file "XXXX# - 20130410s132159266.jpg" of folder "XXXX" of folder "pierre" of folder "Users" of startup disk of application "Finder", document file "XXXX# - 20130410s132159267.jpg" of folder "XXXX" of folder "pierre" of folder "Users" of startup disk of application "Finder", document file "XXXX# - 20130410s132159268.jpg" of folder "XXXX" of folder "pierre" of folder "Users" of startup disk of application "Finder"}

Maybe you are looking for