Moving Subdirectories Between Directories by Folder Name
up vote
0
down vote
favorite
I have a series of sub-directories, all in one parent-directory, each titled like such:
StringA (Date1) StringW [String10]
StringB (Date2) StringX [String11]
StringB (Date3) StringY [String12]
StringC (Date4) StringZ [String13]
I also have a different folder full of subdirectories, one for each unique string to lead the title of a subdirectory from the prior list. Proceeding from the above example, it would go:
StringA
StringB
StringC
Is there a workable means of moving each extended-title sub-directory into the short-titled sub-directory that matches its leading string?
For clarity, my desired result would be folders nested in the following order:
StringA/StringA (Date1) StringW [String10]
StringB/StringB (Date2) StringX [String11]
StringB/StringB (Date3) StringY [String12]
StringC/StringC (Date4) StringZ [String13]
files batch-rename
add a comment |
up vote
0
down vote
favorite
I have a series of sub-directories, all in one parent-directory, each titled like such:
StringA (Date1) StringW [String10]
StringB (Date2) StringX [String11]
StringB (Date3) StringY [String12]
StringC (Date4) StringZ [String13]
I also have a different folder full of subdirectories, one for each unique string to lead the title of a subdirectory from the prior list. Proceeding from the above example, it would go:
StringA
StringB
StringC
Is there a workable means of moving each extended-title sub-directory into the short-titled sub-directory that matches its leading string?
For clarity, my desired result would be folders nested in the following order:
StringA/StringA (Date1) StringW [String10]
StringB/StringB (Date2) StringX [String11]
StringB/StringB (Date3) StringY [String12]
StringC/StringC (Date4) StringZ [String13]
files batch-rename
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a series of sub-directories, all in one parent-directory, each titled like such:
StringA (Date1) StringW [String10]
StringB (Date2) StringX [String11]
StringB (Date3) StringY [String12]
StringC (Date4) StringZ [String13]
I also have a different folder full of subdirectories, one for each unique string to lead the title of a subdirectory from the prior list. Proceeding from the above example, it would go:
StringA
StringB
StringC
Is there a workable means of moving each extended-title sub-directory into the short-titled sub-directory that matches its leading string?
For clarity, my desired result would be folders nested in the following order:
StringA/StringA (Date1) StringW [String10]
StringB/StringB (Date2) StringX [String11]
StringB/StringB (Date3) StringY [String12]
StringC/StringC (Date4) StringZ [String13]
files batch-rename
I have a series of sub-directories, all in one parent-directory, each titled like such:
StringA (Date1) StringW [String10]
StringB (Date2) StringX [String11]
StringB (Date3) StringY [String12]
StringC (Date4) StringZ [String13]
I also have a different folder full of subdirectories, one for each unique string to lead the title of a subdirectory from the prior list. Proceeding from the above example, it would go:
StringA
StringB
StringC
Is there a workable means of moving each extended-title sub-directory into the short-titled sub-directory that matches its leading string?
For clarity, my desired result would be folders nested in the following order:
StringA/StringA (Date1) StringW [String10]
StringB/StringB (Date2) StringX [String11]
StringB/StringB (Date3) StringY [String12]
StringC/StringC (Date4) StringZ [String13]
files batch-rename
files batch-rename
edited Oct 30 at 2:55
asked Oct 30 at 2:36
Igsnar Lobek
113
113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Try following script
foo="/path/to/folder/containing/short-titled-directories"
bar="/path/to/folder/containing/extended-titled-directories"
for subdir in $foo/*
do
if [[ -d "$subdir" ]]
then
folder_to_move=$(ls $bar | grep "$subdir")
mv "$bar/$folder_to_move" "$subdir/$folder_to_move"
fi
done
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Try following script
foo="/path/to/folder/containing/short-titled-directories"
bar="/path/to/folder/containing/extended-titled-directories"
for subdir in $foo/*
do
if [[ -d "$subdir" ]]
then
folder_to_move=$(ls $bar | grep "$subdir")
mv "$bar/$folder_to_move" "$subdir/$folder_to_move"
fi
done
add a comment |
up vote
0
down vote
Try following script
foo="/path/to/folder/containing/short-titled-directories"
bar="/path/to/folder/containing/extended-titled-directories"
for subdir in $foo/*
do
if [[ -d "$subdir" ]]
then
folder_to_move=$(ls $bar | grep "$subdir")
mv "$bar/$folder_to_move" "$subdir/$folder_to_move"
fi
done
add a comment |
up vote
0
down vote
up vote
0
down vote
Try following script
foo="/path/to/folder/containing/short-titled-directories"
bar="/path/to/folder/containing/extended-titled-directories"
for subdir in $foo/*
do
if [[ -d "$subdir" ]]
then
folder_to_move=$(ls $bar | grep "$subdir")
mv "$bar/$folder_to_move" "$subdir/$folder_to_move"
fi
done
Try following script
foo="/path/to/folder/containing/short-titled-directories"
bar="/path/to/folder/containing/extended-titled-directories"
for subdir in $foo/*
do
if [[ -d "$subdir" ]]
then
folder_to_move=$(ls $bar | grep "$subdir")
mv "$bar/$folder_to_move" "$subdir/$folder_to_move"
fi
done
answered Nov 28 at 10:45
francescop21
11817
11817
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1088441%2fmoving-subdirectories-between-directories-by-folder-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown