2

I have a list of 200 filenames. I need to find these files, which are located in different subfolders, by their filename and copy them into one separate folder. I'm using Windows 7. How do I do that?

Thanks, Natalya

1
  • 1
    You can use a recursive file search using powershell which is built into Windows 7.
    – Ramhound
    May 27, 2015 at 18:49

3 Answers 3

1

My suggestion is to go to Ninite.com, and download the freeware tool called "Everything". it's a simple windows search tool. After install, give it 5 minutes or so to index your files.

In the search field, type your search term, and you'll get instant results, like you do on Google. Upon seeing the results, you can then manipulate the files directly in the Everything search window, such as you can in Windows explorer. You could 'select all' and then copy them, and then in Win Explorer go to the folder you want them and paste them.

Everything is a really nice tool. You don't even need to type the entire filename, just part of it, e.g. 'eag mp3' will return all MP3's with 'eag' in the filename, such as 'eagles - song name.mp3'

3
  • Thanks, I downloaded Everything. However, it doesn't return any results when I put a list of filenames in the search (tried comma delimited, OR deliminted, space delimited) which is what I was hoping to do. There's an Open File List option but it expects a file with the *.efu extension and I'm not even sure that this is what I'm looking for...
    – Natalya
    May 27, 2015 at 20:56
  • @Natalya, here is the page with the search methods. I know Everything is pretty powerful, and I believe even supports regex searching. voidtools.com/support/everything/searching
    – user438353
    May 27, 2015 at 21:00
  • Why go to Ninite when Everything is available from its own site as both installer and portable versions?
    – Karan
    May 27, 2015 at 21:39
1

Here you go. Do the dry run first. Read comments carefully.

The file fullfilenames.txt will persist so you have a record of each file that was found. If you need to run this more than once and want to keep the file either move or rename it.

A logfile 'movelog.txt' will be created. As above, either move or rename it if you want to keep it after each run.

# Set your search directory and destination directory
$destdir = "[destination for files]"
$searchdir = "[top dir of search path]"

# Create empty file to contain the full path info for each file
echo $null > fullfilenames.txt
# Create array from your list of filenames
$filenames = Get-Content filenames.txt
# For each file in array of filenames get fullpath and assign var $fullname
foreach ($file in $filenames) {
     $fullname = Get-ChildItem $searchdir | Where-Object {$_.PSIsContainer -eq $False -and ($_.Name) -eq $file} | ForEach-Object {$_.FullName}
     # Add full path of file to fullfilenames.txt
     echo $fullname >> fullfilenames.txt
     # Uncomment next two lines for troubleshooting & dry run
     #echo $file
     #Write-Host $fullname
}

# Create array from new list of files with full path info and then move each file to destination.
# For troubleshooting & dry run, comment out following two lines.
$filenames = Get-Content fullfilenames.txt
echo $null > movelog.txt
foreach ( $file in $filenames ) {
    Move-Item $file $destdir
    # Log success/fail of each move
    echo "$(Get-Date -f o) $? $file" >> movelog.txt
}

Note: This is a powershell script. Save it as whatever.ps1 and run it in the PowerShell console.

Enjoy

4
  • Thanks, this worked! I ended up simplifying this file because I already had a text file with filenames including full path -
    – Natalya
    May 27, 2015 at 23:12
  • $destdir =C:\Docs\SSIS\SSISPackageMovetoEnwisen04\AListOfEffectedDTSConfigFiles" $searchdir = "C:\Docs\SSIS\SSISPackageMovetoEnwisen04\SSIS-DTS\SSIS-DTS" # For troubleshooting & dry run, comment out following two lines. $filenames = Get-Content C:\Docs\SSIS\SSISPackageMovetoEnwisen04\AListOfEffectedDTSConfigFiles\DTSConfigFilesFullPath.txt echo $null > movelog.txt foreach ( $file in $filenames ) { Move-Item $file $destdir # Log success/fail of each move echo "$(Get-Date -f o) $? $file" >> movelog.txt
    – Natalya
    May 27, 2015 at 23:15
  • Perfect. Glad to have helped. May 27, 2015 at 23:17
  • Don't forget to mark it as the correct answer. Thanks. May 28, 2015 at 1:11
0

You can search for a list of files in "Everything" by delimiting with |.

For example: file1|file2|file3|file4

Link to dowload "Everything": https://www.voidtools.com/downloads/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .