Whitelist file extensions in directory?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Is it possible to whitelist specific file extensions for folders?
For example: I would like to move music albums to a folder, but I don't want the cover art to be transferred by disallowing *.png, *.jpg, etc.,...
filesystems
add a comment |Â
up vote
0
down vote
favorite
Is it possible to whitelist specific file extensions for folders?
For example: I would like to move music albums to a folder, but I don't want the cover art to be transferred by disallowing *.png, *.jpg, etc.,...
filesystems
1
Look intorsync
, it has multiple filter options.
â don_crissti
Sep 19 at 21:24
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Is it possible to whitelist specific file extensions for folders?
For example: I would like to move music albums to a folder, but I don't want the cover art to be transferred by disallowing *.png, *.jpg, etc.,...
filesystems
Is it possible to whitelist specific file extensions for folders?
For example: I would like to move music albums to a folder, but I don't want the cover art to be transferred by disallowing *.png, *.jpg, etc.,...
filesystems
filesystems
edited Sep 19 at 22:23
Goro
6,16552763
6,16552763
asked Sep 19 at 21:06
Kalim
11
11
1
Look intorsync
, it has multiple filter options.
â don_crissti
Sep 19 at 21:24
add a comment |Â
1
Look intorsync
, it has multiple filter options.
â don_crissti
Sep 19 at 21:24
1
1
Look into
rsync
, it has multiple filter options.â don_crissti
Sep 19 at 21:24
Look into
rsync
, it has multiple filter options.â don_crissti
Sep 19 at 21:24
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
0
down vote
You can either do the filtering on copying, say, in the copy script. Or you can apply the filter after the copy operation, removing what's not allowed or needed.
add a comment |Â
up vote
0
down vote
The question is certainly broader than the issue so the answer may vary.
Originally, Unix-like systems do not know the concept of file extension although some software may identify extensions to adapt their operations.
Moreover, a pathname expansion must match existing files or directories located on a specified level in the file system (hierarchical filesystem).
mv
can move an entire directory hierarchy, therefore, mv
also moves files located in matching directories, indistinctly.
A simple solution is to remove the read permission on the wanted files to prevent them to be copied.
prompt% cp -vr album /tmp
'album/' -> '/tmp/album'
'album/song.mp3' -> '/tmp/album/song.mp3'
'album/covert.png' -> '/tmp/album/covert.png'
cp: cannot open 'album/covert.png' for reading: Permission denied
prompt% ls -l album/covert.png
--w-r--r-- user user 8 Sep 07:27 album/covert.png
Files are transferred in the target directory except files that are protected for reading.
add a comment |Â
up vote
0
down vote
The naive way to solve this is to copy everything and then to delete the file you don't want.
Using rsync
to copy the whole source
directory structure to target
, then find
to delete the files you don't want from target
:
rsync -a source/ target
find target -type f ( -name '*.jpg' -o -name '*.png' ) -delete
A more streamlined way to do this is to use the filtering capabilities of rsync
to not transfer the files you don't want:
rsync -a --exclude='*.png' --exclude='*.jpg' source/ target
In both of these cases, you might possibly want to add --delete
and/or --delete-excluded
to the rsync
invocation if you want to delete files not present in the source directory (if target
already contains stuff and you want the two directories to be identical apart from those image files).
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can either do the filtering on copying, say, in the copy script. Or you can apply the filter after the copy operation, removing what's not allowed or needed.
add a comment |Â
up vote
0
down vote
You can either do the filtering on copying, say, in the copy script. Or you can apply the filter after the copy operation, removing what's not allowed or needed.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can either do the filtering on copying, say, in the copy script. Or you can apply the filter after the copy operation, removing what's not allowed or needed.
You can either do the filtering on copying, say, in the copy script. Or you can apply the filter after the copy operation, removing what's not allowed or needed.
edited Sep 20 at 17:11
answered Sep 19 at 21:12
Tomasz
8,43552560
8,43552560
add a comment |Â
add a comment |Â
up vote
0
down vote
The question is certainly broader than the issue so the answer may vary.
Originally, Unix-like systems do not know the concept of file extension although some software may identify extensions to adapt their operations.
Moreover, a pathname expansion must match existing files or directories located on a specified level in the file system (hierarchical filesystem).
mv
can move an entire directory hierarchy, therefore, mv
also moves files located in matching directories, indistinctly.
A simple solution is to remove the read permission on the wanted files to prevent them to be copied.
prompt% cp -vr album /tmp
'album/' -> '/tmp/album'
'album/song.mp3' -> '/tmp/album/song.mp3'
'album/covert.png' -> '/tmp/album/covert.png'
cp: cannot open 'album/covert.png' for reading: Permission denied
prompt% ls -l album/covert.png
--w-r--r-- user user 8 Sep 07:27 album/covert.png
Files are transferred in the target directory except files that are protected for reading.
add a comment |Â
up vote
0
down vote
The question is certainly broader than the issue so the answer may vary.
Originally, Unix-like systems do not know the concept of file extension although some software may identify extensions to adapt their operations.
Moreover, a pathname expansion must match existing files or directories located on a specified level in the file system (hierarchical filesystem).
mv
can move an entire directory hierarchy, therefore, mv
also moves files located in matching directories, indistinctly.
A simple solution is to remove the read permission on the wanted files to prevent them to be copied.
prompt% cp -vr album /tmp
'album/' -> '/tmp/album'
'album/song.mp3' -> '/tmp/album/song.mp3'
'album/covert.png' -> '/tmp/album/covert.png'
cp: cannot open 'album/covert.png' for reading: Permission denied
prompt% ls -l album/covert.png
--w-r--r-- user user 8 Sep 07:27 album/covert.png
Files are transferred in the target directory except files that are protected for reading.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The question is certainly broader than the issue so the answer may vary.
Originally, Unix-like systems do not know the concept of file extension although some software may identify extensions to adapt their operations.
Moreover, a pathname expansion must match existing files or directories located on a specified level in the file system (hierarchical filesystem).
mv
can move an entire directory hierarchy, therefore, mv
also moves files located in matching directories, indistinctly.
A simple solution is to remove the read permission on the wanted files to prevent them to be copied.
prompt% cp -vr album /tmp
'album/' -> '/tmp/album'
'album/song.mp3' -> '/tmp/album/song.mp3'
'album/covert.png' -> '/tmp/album/covert.png'
cp: cannot open 'album/covert.png' for reading: Permission denied
prompt% ls -l album/covert.png
--w-r--r-- user user 8 Sep 07:27 album/covert.png
Files are transferred in the target directory except files that are protected for reading.
The question is certainly broader than the issue so the answer may vary.
Originally, Unix-like systems do not know the concept of file extension although some software may identify extensions to adapt their operations.
Moreover, a pathname expansion must match existing files or directories located on a specified level in the file system (hierarchical filesystem).
mv
can move an entire directory hierarchy, therefore, mv
also moves files located in matching directories, indistinctly.
A simple solution is to remove the read permission on the wanted files to prevent them to be copied.
prompt% cp -vr album /tmp
'album/' -> '/tmp/album'
'album/song.mp3' -> '/tmp/album/song.mp3'
'album/covert.png' -> '/tmp/album/covert.png'
cp: cannot open 'album/covert.png' for reading: Permission denied
prompt% ls -l album/covert.png
--w-r--r-- user user 8 Sep 07:27 album/covert.png
Files are transferred in the target directory except files that are protected for reading.
edited Sep 21 at 6:57
answered Sep 20 at 14:39
Fólkvangr
37110
37110
add a comment |Â
add a comment |Â
up vote
0
down vote
The naive way to solve this is to copy everything and then to delete the file you don't want.
Using rsync
to copy the whole source
directory structure to target
, then find
to delete the files you don't want from target
:
rsync -a source/ target
find target -type f ( -name '*.jpg' -o -name '*.png' ) -delete
A more streamlined way to do this is to use the filtering capabilities of rsync
to not transfer the files you don't want:
rsync -a --exclude='*.png' --exclude='*.jpg' source/ target
In both of these cases, you might possibly want to add --delete
and/or --delete-excluded
to the rsync
invocation if you want to delete files not present in the source directory (if target
already contains stuff and you want the two directories to be identical apart from those image files).
add a comment |Â
up vote
0
down vote
The naive way to solve this is to copy everything and then to delete the file you don't want.
Using rsync
to copy the whole source
directory structure to target
, then find
to delete the files you don't want from target
:
rsync -a source/ target
find target -type f ( -name '*.jpg' -o -name '*.png' ) -delete
A more streamlined way to do this is to use the filtering capabilities of rsync
to not transfer the files you don't want:
rsync -a --exclude='*.png' --exclude='*.jpg' source/ target
In both of these cases, you might possibly want to add --delete
and/or --delete-excluded
to the rsync
invocation if you want to delete files not present in the source directory (if target
already contains stuff and you want the two directories to be identical apart from those image files).
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The naive way to solve this is to copy everything and then to delete the file you don't want.
Using rsync
to copy the whole source
directory structure to target
, then find
to delete the files you don't want from target
:
rsync -a source/ target
find target -type f ( -name '*.jpg' -o -name '*.png' ) -delete
A more streamlined way to do this is to use the filtering capabilities of rsync
to not transfer the files you don't want:
rsync -a --exclude='*.png' --exclude='*.jpg' source/ target
In both of these cases, you might possibly want to add --delete
and/or --delete-excluded
to the rsync
invocation if you want to delete files not present in the source directory (if target
already contains stuff and you want the two directories to be identical apart from those image files).
The naive way to solve this is to copy everything and then to delete the file you don't want.
Using rsync
to copy the whole source
directory structure to target
, then find
to delete the files you don't want from target
:
rsync -a source/ target
find target -type f ( -name '*.jpg' -o -name '*.png' ) -delete
A more streamlined way to do this is to use the filtering capabilities of rsync
to not transfer the files you don't want:
rsync -a --exclude='*.png' --exclude='*.jpg' source/ target
In both of these cases, you might possibly want to add --delete
and/or --delete-excluded
to the rsync
invocation if you want to delete files not present in the source directory (if target
already contains stuff and you want the two directories to be identical apart from those image files).
answered Sep 21 at 9:19
Kusalananda
108k14209332
108k14209332
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%2f470133%2fwhitelist-file-extensions-in-directory%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
1
Look into
rsync
, it has multiple filter options.â don_crissti
Sep 19 at 21:24