Search code examples
bashfilemovedirectory

Move files from multiple folders to multiple folders in Linux


How can I move files from multiple folders to another location. For example if I have 3 folders with name /test/folder1, /test/folder2, /test/folder3 and I want to move the contents of these folders into another location like /temp/folder1, /temp/folder2 /temp/folder3 using a script. I do not want to move these folders, instead I want to move the files inside these folders. Please Help


Solution

  • Something like

    cd test
    for dir in folder*; do
        mv "$dir/*" "/temp/$dir"
    done