Preface: I’m not much of a shell-scripter, in fact not a shell-scripter at all.
I have a folder (
) with many thousand files in it, with varying extensions and random names. None of the file names have spaces in them. There are no subfolders.
I have a plain text file (
) with a few hundred file names, all of them without extensions
. All the file names have corresponding files in
, but with varying extensions. Some may have more than one corresponding file in
with different extensions.
An example from
These might, for example, correspond to the following files in
(Note the two files named
with different extensions.)
I am working on an OS X (10.11) machine. What I need to do is copy all the files in
that match a file name in
I’ve been searching and Googling like mad for a bit now, and I’ve found bucketloads of people explaining how to extract file names without extensions, find and copy all files that have no extension, and various tangentially related issues—but I can’t find anything that really helps me figure out how to do this in particular. Doing a
cp ˋcat filelist.txtˋ folder/copiedfiles/
would work (as far as I can tell) if the file names in the text file included extensions; but they don’t, so it doesn’t.
What is the simplest (and preferably fastest) way to do this?
1 What I need to do is exactly the same as in this question, but that one is specifically asking about batch-file, which is a very different kettle of sea-dwellers.