Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy files with different names

Posted on 2006-11-01
1
Medium Priority
?
285 Views
Last Modified: 2010-04-21
I’m trying to copy files from directory “dirA” to another directory “dirB”.  In dirA I have a number of files which have same names but different extensions:
-      opt0000.wav
-      opt0000.gsm
-      opt0000.txt
There aren’t always three files, sometimes there is only wav and gsm, sometimes there is only gsm and txt and so on, so the only constant I can rely on is the name “opt0000”.

Now, I’m trying to copy these files to dirB, however, the problem is that I need to be able to change the name from opt0000 to, for example, opt0020, so I can’t use “cp dirA/opt0000* dirB/.”.

Is there a command that can do something like this?

Thanks,
Kate
0
Comment
Question by:kasiencja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 17854321
perl -e '$x=$_,s#dirA/opt0000#dirB/opt0020#,system"cp $x $_" for <dirA/opt0000*>'
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question