Terminal – Quick Way to Rename Files with Special Structure

filesystemrenameterminal

I checked out the solution here, but it is not adressing my problem too well, because it does not use the specific structure of my naming.

I have a collection of files, enumerated and named in a systematic way, for instance

filep-x

where x is a number that can be quite large and p is a marker for a "makrocollection". I would like to copy all files in such a makrocollection as a template and automatically rename all files copied as

fileq-x

With other words, is there an option that I can replace names automatically using the terminal (like it is possible in many editors) without working with additional documents?

Thank you in advance!

Best Answer

This could be a job for pax, assuming that there is a consistent naming convention.

cd directory

pax -rws/filep/fileq/ filep-* /path/to/copy/directory