Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

bash - Linux: Move a batch of files and rename?

I'm currently trying to move and rename a batch of files. The following for loop moves the .jpeg files into each subject's folder (subjects.txt is just a text file containing a column of IDs):

for i in `awk '{print $1}' data/subjects.txt`; do find data/ -name ${i}*_img.jpeg | xargs -I file cp file data/${i}/ ; done

However, renaming each file to "img.jpeg" hasn't worked so far:

for i in `awk '{print $1}' data/subjects.txt`; do find data/ -name ${i}*_img.jpeg | xargs -I file cp file data/${i}/img.jpeg ; done

Please let me know if you have any suggestions!

I would like to achieve the following:

data/subject_1/img.jpeg
data/subject_2/img.jpeg
data/subject_3/img.jpeg
question from:https://stackoverflow.com/questions/65875838/linux-move-a-batch-of-files-and-rename

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...