Whitelist file extensions in directory?

The name of the pictureThe name of the pictureThe name of the pictureClash 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.,...










share|improve this question



















  • 1




    Look into rsync, it has multiple filter options.
    – don_crissti
    Sep 19 at 21:24















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.,...










share|improve this question



















  • 1




    Look into rsync, it has multiple filter options.
    – don_crissti
    Sep 19 at 21:24













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.,...










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 19 at 22:23









Goro

6,16552763




6,16552763










asked Sep 19 at 21:06









Kalim

11




11







  • 1




    Look into rsync, it has multiple filter options.
    – don_crissti
    Sep 19 at 21:24













  • 1




    Look into rsync, 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











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.






share|improve this answer





























    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.






    share|improve this answer





























      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).






      share|improve this answer




















        Your Answer







        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "106"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        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






























        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.






        share|improve this answer


























          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.






          share|improve this answer
























            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.






            share|improve this answer














            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.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 20 at 17:11

























            answered Sep 19 at 21:12









            Tomasz

            8,43552560




            8,43552560






















                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.






                share|improve this answer


























                  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.






                  share|improve this answer
























                    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.






                    share|improve this answer














                    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.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Sep 21 at 6:57

























                    answered Sep 20 at 14:39









                    Fólkvangr

                    37110




                    37110




















                        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).






                        share|improve this answer
























                          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).






                          share|improve this answer






















                            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).






                            share|improve this answer












                            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).







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Sep 21 at 9:19









                            Kusalananda

                            108k14209332




                            108k14209332



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                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













































































                                Popular posts from this blog

                                How to check contact read email or not when send email to Individual?

                                Bahrain

                                Postfix configuration issue with fips on centos 7; mailgun relay