How do I scp a filename with spaces?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
6
down vote

favorite












I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:



scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures


However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.



Can someone fill me in on what I'm doing wrong here?



(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:



scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures


and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)







share|improve this question





















  • Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
    – pauljohn32
    Jul 14 '16 at 4:43










  • That's fine, unless you're scp'ing files that you didn't name.
    – Alcuin Arundel
    Jul 14 '16 at 4:46














up vote
6
down vote

favorite












I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:



scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures


However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.



Can someone fill me in on what I'm doing wrong here?



(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:



scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures


and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)







share|improve this question





















  • Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
    – pauljohn32
    Jul 14 '16 at 4:43










  • That's fine, unless you're scp'ing files that you didn't name.
    – Alcuin Arundel
    Jul 14 '16 at 4:46












up vote
6
down vote

favorite









up vote
6
down vote

favorite











I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:



scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures


However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.



Can someone fill me in on what I'm doing wrong here?



(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:



scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures


and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)







share|improve this question













I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:



scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures


However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.



Can someone fill me in on what I'm doing wrong here?



(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:



scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures


and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)









share|improve this question












share|improve this question




share|improve this question








edited Jun 12 at 9:09









muru

128k19269459




128k19269459









asked Apr 15 '16 at 20:58









Alcuin Arundel

2,00711022




2,00711022











  • Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
    – pauljohn32
    Jul 14 '16 at 4:43










  • That's fine, unless you're scp'ing files that you didn't name.
    – Alcuin Arundel
    Jul 14 '16 at 4:46
















  • Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
    – pauljohn32
    Jul 14 '16 at 4:43










  • That's fine, unless you're scp'ing files that you didn't name.
    – Alcuin Arundel
    Jul 14 '16 at 4:46















Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
– pauljohn32
Jul 14 '16 at 4:43




Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
– pauljohn32
Jul 14 '16 at 4:43












That's fine, unless you're scp'ing files that you didn't name.
– Alcuin Arundel
Jul 14 '16 at 4:46




That's fine, unless you're scp'ing files that you didn't name.
– Alcuin Arundel
Jul 14 '16 at 4:46










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:



  1. scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .

  2. scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .

  3. scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .

All should work but some are syntactically easier to understand than others...



References:



  • How to escape spaces in path during scp copy in linux?





share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f757824%2fhow-do-i-scp-a-filename-with-spaces%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:



    1. scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .

    2. scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .

    3. scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .

    All should work but some are syntactically easier to understand than others...



    References:



    • How to escape spaces in path during scp copy in linux?





    share|improve this answer



























      up vote
      6
      down vote



      accepted










      Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:



      1. scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .

      2. scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .

      3. scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .

      All should work but some are syntactically easier to understand than others...



      References:



      • How to escape spaces in path during scp copy in linux?





      share|improve this answer

























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:



        1. scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .

        2. scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .

        3. scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .

        All should work but some are syntactically easier to understand than others...



        References:



        • How to escape spaces in path during scp copy in linux?





        share|improve this answer















        Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:



        1. scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .

        2. scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .

        3. scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .

        All should work but some are syntactically easier to understand than others...



        References:



        • How to escape spaces in path during scp copy in linux?






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Jun 12 at 10:28


























        answered Jul 14 '16 at 2:00









        andrew.46

        20.2k1463138




        20.2k1463138






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f757824%2fhow-do-i-scp-a-filename-with-spaces%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error

            How do I move numbers in filenames, in a batch renaming operation?