Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Tough Challenge: Can you automatically select only the files in a directory whose filenames appear in a spreadsheet?

Let's say you have a column of file names in a spreadsheet (ie - 12F.jpg, 12G.jpg, 27H.jpg,  etc)

You also have a folder full of files.  Some of the files match the ones in your spreadsheet (ie - 12F.jpg, 12G.jpg, 27H.jpg).   However, some of the files in the folder do not match the ones in your spreadsheet.

Is there an way to automatically select only the jpg files that are in the spreadsheet?  That way you can make a copy of only those files for instance.

Thanks so much in advance.
0
furniturepeople
Asked:
furniturepeople
1 Solution
 
Saqib Husain, SyedEngineerCommented:
One way to do this is to do the copy with the help of VBA.

Loop through all the files listed and copy them to the desired destination.

Use an On Error statement to ignore the copy command if the file is not present.
0
 
furniturepeopleAuthor Commented:
Thanks, Is there a way to do it without VBA?  I don't know how to use VBA.
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
You could highlight the whole column, copy it to the clipboard (Ctrl-C), then paste it (Ctrl-V) into a text file using whatever text editor you prefer, such as Notepad, Notepad++, Metapad, whatever. Once the file names are in a text file, you can manipulate them however you want, such as prefixing each file name with "copy" and suffixing each one with "D:\saved_files". Regards, Joe
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LeeTutorretiredCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
There is definitely enough information to confirm an answer. I tested the solution proposed in http:#a39730202 – it works perfectly. I used the technique to copy all of the file names in column A of a spreadsheet to a text file (.BAT) in my favorite editor. I then used a macro to automatically prefix each file name with "copy" and suffix each file name with "D:\saved_files". I then ran the batch file – worked fine. If the OP (or CV) needs more info, please let me know. Regards, Joe
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Netminder,
Thank you! Regards, Joe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now