Wednesday, May 2, 2018

unix - Copy and rename multiple files in one step by txt list

I have list of files what I have to rename. There is no sequence or pattern in renaming therefore I use a .txt files to do it. I can rename and copy files in separate step but I would like to combine this process into one step. The challenging part, why I am going to do it in one step, is some source file should be renamed (and copied) to multiple files.



Example:




source-file-1.jpg -> renamed-file-1.jpg



source-file-1.jpg -> renamed-file-2.jpg



source-file-1.jpg -> renamed-file-3.jpg



I use following xargs commends to rename and copy files.





xargs -a copy.txt cp -t /new-folder



xargs -a rename.txt -n 2 mv




It is possible co combine these commands? I hope if I copy files first I could achieve my goal.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...