Move multiple files with same name in same directory

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











up vote
0
down vote

favorite












I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt



How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt



Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.



And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.










share|improve this question
















bumped to the homepage by Community♦ 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Thanks @icarus. Have updated the description with a detailed scenario.
    – Dud
    Nov 28 '16 at 2:44










  • Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
    – icarus
    Nov 28 '16 at 2:47










  • Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
    – Dud
    Nov 28 '16 at 2:52






  • 1




    Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
    – icarus
    Nov 28 '16 at 3:02














up vote
0
down vote

favorite












I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt



How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt



Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.



And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.










share|improve this question
















bumped to the homepage by Community♦ 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Thanks @icarus. Have updated the description with a detailed scenario.
    – Dud
    Nov 28 '16 at 2:44










  • Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
    – icarus
    Nov 28 '16 at 2:47










  • Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
    – Dud
    Nov 28 '16 at 2:52






  • 1




    Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
    – icarus
    Nov 28 '16 at 3:02












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt



How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt



Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.



And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.










share|improve this question















I have a directory with multiple files of same name.
../directory ls
File.txt
File.txt
File1.txt



How can I move all files to a new directory (/new) using mv
../new ls
File.txt
File.txt
File1.txt



Update:
The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.



And by "processed" all I am doing is Copying it to one Dir. And Archive in another using MV. Using cp n mv only one instance of the file is being processed.







command-line files mv






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '16 at 2:43

























asked Nov 28 '16 at 2:20









Dud

84




84





bumped to the homepage by Community♦ 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community♦ 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.













  • Thanks @icarus. Have updated the description with a detailed scenario.
    – Dud
    Nov 28 '16 at 2:44










  • Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
    – icarus
    Nov 28 '16 at 2:47










  • Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
    – Dud
    Nov 28 '16 at 2:52






  • 1




    Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
    – icarus
    Nov 28 '16 at 3:02
















  • Thanks @icarus. Have updated the description with a detailed scenario.
    – Dud
    Nov 28 '16 at 2:44










  • Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
    – icarus
    Nov 28 '16 at 2:47










  • Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
    – Dud
    Nov 28 '16 at 2:52






  • 1




    Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
    – icarus
    Nov 28 '16 at 3:02















Thanks @icarus. Have updated the description with a detailed scenario.
– Dud
Nov 28 '16 at 2:44




Thanks @icarus. Have updated the description with a detailed scenario.
– Dud
Nov 28 '16 at 2:44












Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
– icarus
Nov 28 '16 at 2:47




Ah, so does this mean that you have a fixed name, e.g. results, which is being pushed in via FTP, and you need to move this to a variable filename like Archive/results.2016.11.27.1315 ?
– icarus
Nov 28 '16 at 2:47












Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
– Dud
Nov 28 '16 at 2:52




Yes. I need to handle multiple instances of the file (which does has a fixed name). Say suppose I have input.txt with 10 EMP details and I unable to process the data. When the next set of file comes with the same name, I am able to move only one file for processing. The most recent one.
– Dud
Nov 28 '16 at 2:52




1




1




Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
– icarus
Nov 28 '16 at 3:02




Because you have a fixed filename, the FTP process will overwrite the previous input.txt, so you will only have a single file called input.txt at a time (which will be the most recent one).
– icarus
Nov 28 '16 at 3:02










2 Answers
2






active

oldest

votes

















up vote
0
down vote














I have a directory with multiple files of same name.




Well, you shouldn't. How can you even cat their contents? (that is, without getting only the first file of the same name each time).




How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt




I'd settle for trying to give them different names:



mv File.txt ../new/File.txt.1
mv File.txt ../new/File.txt.2


and see if you end up with distinct files that way.




Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.




This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.






share|improve this answer






















  • The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
    – Dud
    Nov 28 '16 at 2:40











  • @Dudul Please update your question with more details of this process.
    – DepressedDaniel
    Nov 28 '16 at 2:41










  • Thanks Daniel. I hope this makes it clearer. Should had put in the description.
    – Dud
    Nov 28 '16 at 2:42

















up vote
0
down vote













Can you not use a wildcard to move it all e.g.
mv file.tx* /new/



This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file



Hope that helps.






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: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    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%2f326465%2fmove-multiple-files-with-same-name-in-same-directory%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote














    I have a directory with multiple files of same name.




    Well, you shouldn't. How can you even cat their contents? (that is, without getting only the first file of the same name each time).




    How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt




    I'd settle for trying to give them different names:



    mv File.txt ../new/File.txt.1
    mv File.txt ../new/File.txt.2


    and see if you end up with distinct files that way.




    Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.




    This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.






    share|improve this answer






















    • The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
      – Dud
      Nov 28 '16 at 2:40











    • @Dudul Please update your question with more details of this process.
      – DepressedDaniel
      Nov 28 '16 at 2:41










    • Thanks Daniel. I hope this makes it clearer. Should had put in the description.
      – Dud
      Nov 28 '16 at 2:42














    up vote
    0
    down vote














    I have a directory with multiple files of same name.




    Well, you shouldn't. How can you even cat their contents? (that is, without getting only the first file of the same name each time).




    How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt




    I'd settle for trying to give them different names:



    mv File.txt ../new/File.txt.1
    mv File.txt ../new/File.txt.2


    and see if you end up with distinct files that way.




    Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.




    This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.






    share|improve this answer






















    • The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
      – Dud
      Nov 28 '16 at 2:40











    • @Dudul Please update your question with more details of this process.
      – DepressedDaniel
      Nov 28 '16 at 2:41










    • Thanks Daniel. I hope this makes it clearer. Should had put in the description.
      – Dud
      Nov 28 '16 at 2:42












    up vote
    0
    down vote










    up vote
    0
    down vote










    I have a directory with multiple files of same name.




    Well, you shouldn't. How can you even cat their contents? (that is, without getting only the first file of the same name each time).




    How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt




    I'd settle for trying to give them different names:



    mv File.txt ../new/File.txt.1
    mv File.txt ../new/File.txt.2


    and see if you end up with distinct files that way.




    Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.




    This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.






    share|improve this answer















    I have a directory with multiple files of same name.




    Well, you shouldn't. How can you even cat their contents? (that is, without getting only the first file of the same name each time).




    How can I move all files to a new directory (/new) using mv ../new ls File.txt File.txt File1.txt




    I'd settle for trying to give them different names:



    mv File.txt ../new/File.txt.1
    mv File.txt ../new/File.txt.2


    and see if you end up with distinct files that way.




    Update: The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script.




    This is overwhelmingly unlikely to result in a situation in which you have multiple files with the same name in the same directory. So don't sweat that case, I guess.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 28 '16 at 2:47

























    answered Nov 28 '16 at 2:36









    DepressedDaniel

    3,355413




    3,355413











    • The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
      – Dud
      Nov 28 '16 at 2:40











    • @Dudul Please update your question with more details of this process.
      – DepressedDaniel
      Nov 28 '16 at 2:41










    • Thanks Daniel. I hope this makes it clearer. Should had put in the description.
      – Dud
      Nov 28 '16 at 2:42
















    • The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
      – Dud
      Nov 28 '16 at 2:40











    • @Dudul Please update your question with more details of this process.
      – DepressedDaniel
      Nov 28 '16 at 2:41










    • Thanks Daniel. I hope this makes it clearer. Should had put in the description.
      – Dud
      Nov 28 '16 at 2:42















    The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
    – Dud
    Nov 28 '16 at 2:40





    The files are being FTPed to an UNIX directory by a source system, which needs to be processed using shell script. Once done I need to move multiple instances of the same file (if any) to an Archive directory.
    – Dud
    Nov 28 '16 at 2:40













    @Dudul Please update your question with more details of this process.
    – DepressedDaniel
    Nov 28 '16 at 2:41




    @Dudul Please update your question with more details of this process.
    – DepressedDaniel
    Nov 28 '16 at 2:41












    Thanks Daniel. I hope this makes it clearer. Should had put in the description.
    – Dud
    Nov 28 '16 at 2:42




    Thanks Daniel. I hope this makes it clearer. Should had put in the description.
    – Dud
    Nov 28 '16 at 2:42












    up vote
    0
    down vote













    Can you not use a wildcard to move it all e.g.
    mv file.tx* /new/



    This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file



    Hope that helps.






    share|improve this answer


























      up vote
      0
      down vote













      Can you not use a wildcard to move it all e.g.
      mv file.tx* /new/



      This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file



      Hope that helps.






      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        Can you not use a wildcard to move it all e.g.
        mv file.tx* /new/



        This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file



        Hope that helps.






        share|improve this answer














        Can you not use a wildcard to move it all e.g.
        mv file.tx* /new/



        This will move all files that have a name that starts with file.tx to your directory /new. It will leave behind any files that dont match so file1.txt will stay in the directory. If you want to move any file with name file.txt and file1.txt you could move your wildcard * to after file e.g. file* this will then move any file in that directory that has a name starting with file



        Hope that helps.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 28 '16 at 16:13

























        answered Nov 28 '16 at 15:25









        a.smith

        1481213




        1481213



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f326465%2fmove-multiple-files-with-same-name-in-same-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