S
S
Sergey Bydanov2019-03-18 14:47:45
linux
Sergey Bydanov, 2019-03-18 14:47:45

How to automate file copying with renaming in linux?

There is a source of files with a structure like yyyy\mm\Statistics for yyyymmdd.xls
Files in the source are added every working day. It is necessary to copy all xls files containing the words " Statistics for ", but so that the target file does not have it, that is:
Statistics for 20190318.xls -> 20190318.xls
Is it possible to do this with standard tools or maybe there are some third-party utilities suitable for this task?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaliy Orlov, 2019-03-18
@sergarcada

Here is an example how to copy files from "Statistics for 20190318.xls" format to "20190318.xls"
then tune to your needs, for example, to rename cp, replace it with mv

find -name "*.xls" -exec sh -c 'mv "$1" `echo $1 | grep -o -E "[0-9]+"`.xls' sh {} \;

T
TyzhSysAdmin, 2019-03-18
@POS_troi

You can either use standard tools or write a script in any language available in the system.
Related https://unix.stackexchange.com/questions/227662/ho...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question