Copy Files from one directory to another while creating a new folder for each file, named after the file

Tim Feeney

This is my first time asking a question. I am newly trying to use command line more and more but this problem is beyond my skill.

I want to do a multi part file transfer.

1) I want to take multiple files file_1.md, file_2.md...etc, from original_folderand copy them to target_folder_master

2) I want to take each file, create a new folder based on the name of each file, for instance there should be a folder named file_1 etc within target_folder_master

3) I want to be able to copy each file into its correspondingly named folder

4) and then rename each file in its target folder from its original name to index.md, for instance file_1.md should be renamed index.md with final path ~/file_1/index.md

My hope is that this is all automated.

schrodigerscatcuriosity

Try this:

for file in *.md; do
  mkdir "/path/to/target_folder_master/${file%.*}"
  mv "$file" "/path/to/target_folder_master/${file%.*}/index.md"
done

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NSIS simple copy one file from another folder in program files directory to installation dir not working

From Dev

Copy files from one folder to another but have an interval between each file

From Dev

Copy files from one folder to another based on similar file name

From Dev

FileNotFoundException While trying to copy the file from one directory to another

From Dev

How to copy files from one directory to another after closing the Dolphin file manager in Kubuntu 16.04 LTS?

From Dev

Copy a file from one folder to another folder and rename the file in the new folder with old filename+timestamp

From Dev

Copy file from one folder to another in Java

From Dev

copy file from one folder to another in gradle

From Dev

Delete files from one folder if a similarly named file does not exist in another folder

From Dev

Qt - copy a file from one directory to another

From Dev

Creating copy of a file at one position up in the same folder/directory location

From Dev

Creating copy of a file at one position up in the same folder/directory location

From Dev

Python: Copy identical .csv files from various folders (each folder has one .csv file) into a single folder

From Dev

Python: Copy identical .csv files from various folders (each folder has one .csv file) into a single folder

From Dev

how to copy a column from another file when the ID's matches (multiple files in each folder)

From Dev

Extract a List of .zip files into one new directory each, directory name to be taken from name of the zip file

From Dev

batch file failed and cannot copy file from one directory to another

From Dev

Copying files from multiple (specified) folder paths to another directory while maintaining file structure

From Dev

How to copy and rename a file from one folder to another using Powershell?

From Dev

Shell script to copy a specific file from one folder to another with date

From Dev

How do I copy the latest file from one directory to another?

From Dev

How do I copy the latest file from one directory to another?

From Dev

How can I copy a file from another directory to the current one?

From Dev

Shell script Copy file from one directory to another not working

From Dev

Error while moving the file from one folder to another using shutil

From Dev

Copy files from one folder to another with Groovy

From Dev

Copy files from one directory to another, ignoring files where the destination's file has been modified in the last hour?

From Dev

Need to create a batch file to select one random file from a folder and copy to another folder

From Dev

Need to create a batch file to select one random file from a folder and copy to another folder

Related Related

  1. 1

    NSIS simple copy one file from another folder in program files directory to installation dir not working

  2. 2

    Copy files from one folder to another but have an interval between each file

  3. 3

    Copy files from one folder to another based on similar file name

  4. 4

    FileNotFoundException While trying to copy the file from one directory to another

  5. 5

    How to copy files from one directory to another after closing the Dolphin file manager in Kubuntu 16.04 LTS?

  6. 6

    Copy a file from one folder to another folder and rename the file in the new folder with old filename+timestamp

  7. 7

    Copy file from one folder to another in Java

  8. 8

    copy file from one folder to another in gradle

  9. 9

    Delete files from one folder if a similarly named file does not exist in another folder

  10. 10

    Qt - copy a file from one directory to another

  11. 11

    Creating copy of a file at one position up in the same folder/directory location

  12. 12

    Creating copy of a file at one position up in the same folder/directory location

  13. 13

    Python: Copy identical .csv files from various folders (each folder has one .csv file) into a single folder

  14. 14

    Python: Copy identical .csv files from various folders (each folder has one .csv file) into a single folder

  15. 15

    how to copy a column from another file when the ID's matches (multiple files in each folder)

  16. 16

    Extract a List of .zip files into one new directory each, directory name to be taken from name of the zip file

  17. 17

    batch file failed and cannot copy file from one directory to another

  18. 18

    Copying files from multiple (specified) folder paths to another directory while maintaining file structure

  19. 19

    How to copy and rename a file from one folder to another using Powershell?

  20. 20

    Shell script to copy a specific file from one folder to another with date

  21. 21

    How do I copy the latest file from one directory to another?

  22. 22

    How do I copy the latest file from one directory to another?

  23. 23

    How can I copy a file from another directory to the current one?

  24. 24

    Shell script Copy file from one directory to another not working

  25. 25

    Error while moving the file from one folder to another using shutil

  26. 26

    Copy files from one folder to another with Groovy

  27. 27

    Copy files from one directory to another, ignoring files where the destination's file has been modified in the last hour?

  28. 28

    Need to create a batch file to select one random file from a folder and copy to another folder

  29. 29

    Need to create a batch file to select one random file from a folder and copy to another folder

HotTag

Archive