How to find multi part rar archives, extract them into their directories and remove them if everything successful
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have hundreds of folders with multi part archives inside them.
-FOLDER.1
file.rar
file.r00
file.r01
file.r02
-FOLDER.2
file.rar
file.r00
file.r01
I am using the code below to extract them inside their respective folders and to remove them upon successful extraction,
flock -n locked -c "find . -name '*.rar' -execdir unrar e -o- ; -execdir rm ; && find . -name '*.r[:0-9:][:0-9:]' -exec rm ;"
The problem is if something goes wrong, lets say;
- One of the parts of the archive is corrupted,
- Files are not uploaded yet
This script deletes the multi parts even though extracting is not successful. How can improve this script so it deletes rar files and parts if extraction is successful.
I spend my whole morning to figure this out but so far no success.
find rar
add a comment |Â
up vote
0
down vote
favorite
I have hundreds of folders with multi part archives inside them.
-FOLDER.1
file.rar
file.r00
file.r01
file.r02
-FOLDER.2
file.rar
file.r00
file.r01
I am using the code below to extract them inside their respective folders and to remove them upon successful extraction,
flock -n locked -c "find . -name '*.rar' -execdir unrar e -o- ; -execdir rm ; && find . -name '*.r[:0-9:][:0-9:]' -exec rm ;"
The problem is if something goes wrong, lets say;
- One of the parts of the archive is corrupted,
- Files are not uploaded yet
This script deletes the multi parts even though extracting is not successful. How can improve this script so it deletes rar files and parts if extraction is successful.
I spend my whole morning to figure this out but so far no success.
find rar
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have hundreds of folders with multi part archives inside them.
-FOLDER.1
file.rar
file.r00
file.r01
file.r02
-FOLDER.2
file.rar
file.r00
file.r01
I am using the code below to extract them inside their respective folders and to remove them upon successful extraction,
flock -n locked -c "find . -name '*.rar' -execdir unrar e -o- ; -execdir rm ; && find . -name '*.r[:0-9:][:0-9:]' -exec rm ;"
The problem is if something goes wrong, lets say;
- One of the parts of the archive is corrupted,
- Files are not uploaded yet
This script deletes the multi parts even though extracting is not successful. How can improve this script so it deletes rar files and parts if extraction is successful.
I spend my whole morning to figure this out but so far no success.
find rar
I have hundreds of folders with multi part archives inside them.
-FOLDER.1
file.rar
file.r00
file.r01
file.r02
-FOLDER.2
file.rar
file.r00
file.r01
I am using the code below to extract them inside their respective folders and to remove them upon successful extraction,
flock -n locked -c "find . -name '*.rar' -execdir unrar e -o- ; -execdir rm ; && find . -name '*.r[:0-9:][:0-9:]' -exec rm ;"
The problem is if something goes wrong, lets say;
- One of the parts of the archive is corrupted,
- Files are not uploaded yet
This script deletes the multi parts even though extracting is not successful. How can improve this script so it deletes rar files and parts if extraction is successful.
I spend my whole morning to figure this out but so far no success.
find rar
edited Feb 9 at 7:24
asked Feb 8 at 15:50
user611811
62
62
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20
add a comment |Â
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
The rm
commands must be dependent on the result of the unrar
command where in your example they are all run sequentially whatever happens.
So try something like that instead (on a test directory first!):
flock -n locked -c "find . -name '*.rar' -print0 | xargs -0 -I FILE sh -c "unrar e -o- FILE && rm FILE `basename FILE .rar`.r[:digit:][:digit:]" "
Then the rm
part is executed only if the unrar
command finished successfully.
You will need extra quotes if your file names have spaces.
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
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
The rm
commands must be dependent on the result of the unrar
command where in your example they are all run sequentially whatever happens.
So try something like that instead (on a test directory first!):
flock -n locked -c "find . -name '*.rar' -print0 | xargs -0 -I FILE sh -c "unrar e -o- FILE && rm FILE `basename FILE .rar`.r[:digit:][:digit:]" "
Then the rm
part is executed only if the unrar
command finished successfully.
You will need extra quotes if your file names have spaces.
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
add a comment |Â
up vote
0
down vote
The rm
commands must be dependent on the result of the unrar
command where in your example they are all run sequentially whatever happens.
So try something like that instead (on a test directory first!):
flock -n locked -c "find . -name '*.rar' -print0 | xargs -0 -I FILE sh -c "unrar e -o- FILE && rm FILE `basename FILE .rar`.r[:digit:][:digit:]" "
Then the rm
part is executed only if the unrar
command finished successfully.
You will need extra quotes if your file names have spaces.
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The rm
commands must be dependent on the result of the unrar
command where in your example they are all run sequentially whatever happens.
So try something like that instead (on a test directory first!):
flock -n locked -c "find . -name '*.rar' -print0 | xargs -0 -I FILE sh -c "unrar e -o- FILE && rm FILE `basename FILE .rar`.r[:digit:][:digit:]" "
Then the rm
part is executed only if the unrar
command finished successfully.
You will need extra quotes if your file names have spaces.
The rm
commands must be dependent on the result of the unrar
command where in your example they are all run sequentially whatever happens.
So try something like that instead (on a test directory first!):
flock -n locked -c "find . -name '*.rar' -print0 | xargs -0 -I FILE sh -c "unrar e -o- FILE && rm FILE `basename FILE .rar`.r[:digit:][:digit:]" "
Then the rm
part is executed only if the unrar
command finished successfully.
You will need extra quotes if your file names have spaces.
edited Feb 9 at 14:11
answered Feb 8 at 16:47
Patrick Mevzek
2,0131721
2,0131721
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
add a comment |Â
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
Sorry but I am strugling to understand this; Extraction went OK, deleted .rar file but the rest stays. How can I delete the rest of the files "test_file.r[:0-9:]" rm: cannot remove './test_file.rar.r[:0-9:]': No such file or directory
â user611811
Feb 9 at 7:19
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
I have edited my answer, it should work for all files from .r00 to .r99
â Patrick Mevzek
Feb 9 at 14:11
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%2f422843%2fhow-to-find-multi-part-rar-archives-extract-them-into-their-directories-and-rem%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
how do you expect the event "Files are not uploaded yet" to be detected ?
â RomanPerekhrest
Feb 8 at 16:14
I am depending on successful extraction on that side.
â user611811
Feb 8 at 16:20