Move Files from Directory up one level
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a filestructure with several subfolders where I'd like to search for all subfolder containing a certain string ("sub*") and then move all of the files in these found folders up one level from each of their respective location. And even potentially delete the then empty folder but I could do that with a second step as well.
find recursive move
add a comment |Â
up vote
0
down vote
favorite
I have a filestructure with several subfolders where I'd like to search for all subfolder containing a certain string ("sub*") and then move all of the files in these found folders up one level from each of their respective location. And even potentially delete the then empty folder but I could do that with a second step as well.
find recursive move
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a filestructure with several subfolders where I'd like to search for all subfolder containing a certain string ("sub*") and then move all of the files in these found folders up one level from each of their respective location. And even potentially delete the then empty folder but I could do that with a second step as well.
find recursive move
I have a filestructure with several subfolders where I'd like to search for all subfolder containing a certain string ("sub*") and then move all of the files in these found folders up one level from each of their respective location. And even potentially delete the then empty folder but I could do that with a second step as well.
find recursive move
find recursive move
asked Dec 15 '16 at 12:21
Fabian
85
85
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
This should do it:
find /path/to/base/folder/ -type d -name 'sub*' -exec bash -c 'mv /* "$(dirname )"' ;
NOTE: this will not move hidden files (whose name start with .
)
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
This is the name of a command, seeman dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
add a comment |Â
up vote
0
down vote
find /path/to -type f -execdir mv .. ;
New contributor
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
This should do it:
find /path/to/base/folder/ -type d -name 'sub*' -exec bash -c 'mv /* "$(dirname )"' ;
NOTE: this will not move hidden files (whose name start with .
)
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
This is the name of a command, seeman dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
add a comment |Â
up vote
0
down vote
accepted
This should do it:
find /path/to/base/folder/ -type d -name 'sub*' -exec bash -c 'mv /* "$(dirname )"' ;
NOTE: this will not move hidden files (whose name start with .
)
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
This is the name of a command, seeman dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
This should do it:
find /path/to/base/folder/ -type d -name 'sub*' -exec bash -c 'mv /* "$(dirname )"' ;
NOTE: this will not move hidden files (whose name start with .
)
This should do it:
find /path/to/base/folder/ -type d -name 'sub*' -exec bash -c 'mv /* "$(dirname )"' ;
NOTE: this will not move hidden files (whose name start with .
)
edited Dec 16 '16 at 21:52
answered Dec 15 '16 at 12:35
Narà «nasK
8121619
8121619
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
This is the name of a command, seeman dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
add a comment |Â
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
This is the name of a command, seeman dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
What is "dirname" in this supposed to be?
â Fabian
Dec 15 '16 at 12:36
1
1
This is the name of a command, see
man dirname
â Narà «nasK
Dec 15 '16 at 12:36
This is the name of a command, see
man dirname
â Narà «nasK
Dec 15 '16 at 12:36
1
1
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
Okay, i tried it out. Unfortunately it does not do what I want. it moves the Folder found with "find" up one directory. However what i need is the content IN the folder to be moved up one level (so basically then on the same level as the folder)
â Fabian
Dec 15 '16 at 12:44
add a comment |Â
up vote
0
down vote
find /path/to -type f -execdir mv .. ;
New contributor
add a comment |Â
up vote
0
down vote
find /path/to -type f -execdir mv .. ;
New contributor
add a comment |Â
up vote
0
down vote
up vote
0
down vote
find /path/to -type f -execdir mv .. ;
New contributor
find /path/to -type f -execdir mv .. ;
New contributor
New contributor
answered 6 mins ago
LeoWinterDE
11
11
New contributor
New contributor
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f330600%2fmove-files-from-directory-up-one-level%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password