[英]Copy and Rename files from one location to another using an input file
I need to Copy some files from one location with subfolders to another but at the same time I do need to rename them. 我需要将带有子文件夹的某些文件从一个位置复制到另一位置,但同时我需要重命名它们。 I have the list that has the specific files with their location, where they should copied to and, the new file name. 我有一个列表,其中包含特定文件及其位置,应将其复制到的位置以及新文件名。 I am not fussy about the language and I can modify the input file as per the needs. 我对语言不是很挑剔,可以根据需要修改输入文件。
I have seen multiple questions on that but none of them is actually using a input file to achieve that. 我已经看到了多个问题,但是没有一个实际上是使用输入文件来实现的。
Answering my own question for anybody who needs. 为任何需要的人回答我自己的问题。
#!/usr/bin/bash
while IFS=" " read -r Source Dest OldName NewName
do
FullName="${Dest}""${NewName}"
cd "$Source"
mkdir -p "$Dest"
cp "$OldName" "$FullName"
done < "input.txt"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.