简体   繁体   English

使用输入文件将文件从一个位置复制并重命名到另一位置

[英]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.

相关问题 用于将文件从一个位置复制到另一个位置并重命名的Shell脚本将当前日期添加到每个文件 - Shell script to copy files from one location to another location and rename add the current date to every file Shell 将文件从一个位置复制到另一个位置并重命名的脚本,将当前日期和时间戳添加到 YYYYMMDDHHmmSS 格式的每个文件 - Shell script to copy files from one location to another location and rename add the current date and time stamp to every file in YYYYMMDDHHmmSSformat 在linux中将文件列表从一个位置复制到另一个位置 - Copy list of files from one location to another in linux bash程序可将所有文件从一个位置复制到另一位置 - bash program to copy all files from one location to another 将文件从一个位置复制到另一个位置,无需文件夹 - Copy files from one location to another without folder bash shell使用break将文件从一个位置复制到另一个位置并继续 - bash shell copy the file from one location to another using break and continue 如何自动将文件从一个服务器位置复制到另一个位置并从源位置移动? - How to automate copy files from one server location to another and move from the source location? bash复制文件3次,并使用另一个文件中的行重命名每个文件 - bash to copy file 3 times and rename each using lines in another file 如何编写 bash 脚本将文件从一个基地复制到另一个基地位置 - How to write a bash script to copy files from one base to another base location 使用bash将一个文件中的行内容复制到另一文件中的特定字符位置 - Using bash to copy contents of row in one file to specific character location in another file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM