Search code examples
bashshmovefile-managementfile-move

Moving files from one subdirectory to another II


My directory is like this:

/Users/dave/Desktop/test/untitled_folder_0001/vol_0000
/Users/dave/Desktop/test/untitled_folder_0001/rs

/Users/dave/Desktop/test/untitled_folder_0001/t1
/Users/dave/Desktop/test/untitled_folder_0001/str

I want to move all vol_0000 to rs and t1 to str in 1500~ untitled_folder_**** inside test in a shell script if possible.

I already tried many times, but got no where. im writing this anew because i was not able to get help before. Here is the previous thread! If this was answered i will delete that one for redundancy.

Moving files from one subdirectory to another


Solution

  • Easiest way is probably with a loop.

    for f in /Users/dave/Desktop/test/untitled_folder_*; do
      mv "$f"/vol_0000 "$f"/rs # move everything from `vol_0000` into `rs`
      mv "$f"/t1 "$f"/str
    done
    

    ... assuming I've understood the goal correctly.