Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list file called demo.lst which has a filename demo_one_two_20210203_XM3304.csv. I am looking for a one line command or multiple commands in single line which will read the filename from the list file and move it to a destination by renaming it as shown below.

List File :demo.lst
Contents of List File :demo_one_two_20210203_XM3304.csv
Source File Name :demo_one_two_20210203_XM3304.csv
Target Location: \incc\demo\target
Target File : demo_one_two_20210203.csv

I am using xargs -a demo.lst mv -t incc\demo\target; which is moving the file as is without trimming everythin after _XM. I want to trim everything after _XM while moving the file and append it with .csv


What I have tried:

I am using xargs -a demo.lst mv -t incc\demo\target; which is moving the file as is without trimming everythin after _XM. I want to trim everything after _XM while moving the file and append it with
Posted
Updated 15-Dec-21 4:29am

1 solution

You could use awk and/or cut commands to remove the unwanted text. There is a sample of the cut command in the xargs man page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900