Sample Header Ad - 728x90

GIT move files from folder to subfolder

1 vote
1 answer
2103 views
I have the following folder structure.
Service
|
-- App1
  |
  --- bin
  |
  --- file1
  |
  --- file2
|
--App2
  |
  --- bin
  |
  --- file1
  |
  --- file2
  |
  --- file3
|
--App3
  |
  --- bin
  |
  --- file1
  |
  --- file2
I'm looking to move files only from the root of App folders to their corresponding bin folders whilst preserving GIT history. So the end result should be:
Service
|
-- App1
  |
  --- bin
     |
      --- file1
     |
      --- file2
|
--App2
  |
  --- bin
     |
      --- file1
     |
      --- file2
     |
      --- file3
|
--App3
  |
  --- bin
     |
      --- file1
     |
      --- file2
I attempted the following...
#!/bin/bash

dir1="/c/Service"

subs=ls $dir1

for i in $subs; do
  git mv $dir1/$i/* $dir1/$i/bin/
done
...but see the following errors: *fatal: can not move directory into itself* *fatal: Invalid path '/c': No such file or directory* Any help appreciated.
Asked by Confounder (131 rep)
Jul 29, 2022, 04:38 PM
Last activity: May 15, 2025, 12:09 PM