Skip to main content
added 1 character in body
Source Link
Harry
  • 5
  • 1
  • 3

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy these files within the directories and use the names of the respective directory as the file name. The original filefiles should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy these files within the directories and use the names of the respective directory as the file name. The original file should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy these files within the directories and use the names of the respective directory as the file name. The original files should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

added 5 characters in body
Source Link
Harry
  • 5
  • 1
  • 3

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy this filethese files within the directorydirectories and use the namenames of the respective directory as the file name. The original file should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy this file within the directory and use the name of the respective directory as the file name. The original file should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

I've been using Linux for a few years now, but I'm not very familiar with the console. I can manage simple copy commands, but now I have a requirement that is beyond my knowledge.

I have a large number of directories (folder1, folder2, folder3 etc.). In each of these directories there is a file with the same name (e.g. file.txt). I would now like to batch copy these files within the directories and use the names of the respective directory as the file name. The original file should remain unchanged.

So... 'folder1/file.txt' is to be copied to 'folder1/folder1.txt'.

This means that there should be two files with the same content in each directory, one of which has the same name as the directory.

I assume I need a bash script for the operation, right? And if so, what would this script look like?

I'd appreciate any help.

Harry

edited title
Link
Harry
  • 5
  • 1
  • 3

I'd like to bashbatch copy files in an special way - Do I need a script?

Source Link
Harry
  • 5
  • 1
  • 3
Loading