Windows: copy files and change extension without duplicates Announcing the arrival of Valued...

Okay to merge included columns on otherwise identical indexes?

Echoing a tail command produces unexpected output?

Is it fair for a professor to grade us on the possession of past papers?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?

Single word antonym of "flightless"

3 doors, three guards, one stone

When were vectors invented?

Can I cast Passwall to drop an enemy into a 20-foot pit?

porting install scripts : can rpm replace apt?

How to answer "Have you ever been terminated?"

How does debian/ubuntu knows a package has a updated version

Extract all GPU name, model and GPU ram

How to deal with a team lead who never gives me credit?

How to call a function with default parameter through a pointer to function that is the return of another function?

How much time will it take to get my passport back if I am applying for multiple Schengen visa countries?

Do I really need recursive chmod to restrict access to a folder?

How do I stop a creek from eroding my steep embankment?

What exactly is a "Meth" in Altered Carbon?

Error "illegal generic type for instanceof" when using local classes

Fundamental Solution of the Pell Equation

Why did the Falcon Heavy center core fall off the ASDS OCISLY barge?

List of Python versions

Why are there no cargo aircraft with "flying wing" design?



Windows: copy files and change extension without duplicates



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Can Robocopy monitor files on a time increment of less than one minute?Robocopy; How to copying missing files to a different location from original copy?Script to automate copy files with a pattern over networkAbout robocopy slient operation resultHow to copy a directory on Windows, preserving timestamps of all directories being copiedRobocopy is ignoring /xd directoriesWorking with source files while Robocopy is runningRobocopy: “The system cannot find the path specified.” for cell phone micro SD cardMove a copy of unknown named images and rename - Powershell or Batch ScriptRobocopy mirror when source files have moved directory





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a directory that has image files without extension. Let us say it to be D:initial. Now I want to copy those files over to D:final directory and change the extension to .jpg for each file.



My solution using ROBOCOPY:



@echo off

SET srcDir=D:initial
SET destDir=D:final

echo Copying files from %srcDir%
ROBOCOPY %srcDir% %destDir% /s /min:102400
echo Copying done

cd %destDir%

echo Renaming to JPG
ren *. *.jpg


However, there are certain conditions:




  1. Copy only those files that are greater than 100 KB in size.

  2. Do not delete files in the source directory.

  3. The source directory will at certain periods, get newer files; copy them to the destination directory (manually, no automation needed here)


My solution meets the first two conditions, but when I run again after new files arrive, the older ones get copied over too thus giving error at renaming.










share|improve this question























  • Use the /MAXAGE:n option?

    – DavidPostill
    Jun 13 '18 at 8:13






  • 1





    Your third point says you will do it manually, so where's the problem?

    – Seth
    Jun 13 '18 at 8:13











  • @Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

    – User528491
    Jun 13 '18 at 9:05











  • Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

    – Seth
    Jun 13 '18 at 9:11


















0















I have a directory that has image files without extension. Let us say it to be D:initial. Now I want to copy those files over to D:final directory and change the extension to .jpg for each file.



My solution using ROBOCOPY:



@echo off

SET srcDir=D:initial
SET destDir=D:final

echo Copying files from %srcDir%
ROBOCOPY %srcDir% %destDir% /s /min:102400
echo Copying done

cd %destDir%

echo Renaming to JPG
ren *. *.jpg


However, there are certain conditions:




  1. Copy only those files that are greater than 100 KB in size.

  2. Do not delete files in the source directory.

  3. The source directory will at certain periods, get newer files; copy them to the destination directory (manually, no automation needed here)


My solution meets the first two conditions, but when I run again after new files arrive, the older ones get copied over too thus giving error at renaming.










share|improve this question























  • Use the /MAXAGE:n option?

    – DavidPostill
    Jun 13 '18 at 8:13






  • 1





    Your third point says you will do it manually, so where's the problem?

    – Seth
    Jun 13 '18 at 8:13











  • @Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

    – User528491
    Jun 13 '18 at 9:05











  • Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

    – Seth
    Jun 13 '18 at 9:11














0












0








0








I have a directory that has image files without extension. Let us say it to be D:initial. Now I want to copy those files over to D:final directory and change the extension to .jpg for each file.



My solution using ROBOCOPY:



@echo off

SET srcDir=D:initial
SET destDir=D:final

echo Copying files from %srcDir%
ROBOCOPY %srcDir% %destDir% /s /min:102400
echo Copying done

cd %destDir%

echo Renaming to JPG
ren *. *.jpg


However, there are certain conditions:




  1. Copy only those files that are greater than 100 KB in size.

  2. Do not delete files in the source directory.

  3. The source directory will at certain periods, get newer files; copy them to the destination directory (manually, no automation needed here)


My solution meets the first two conditions, but when I run again after new files arrive, the older ones get copied over too thus giving error at renaming.










share|improve this question














I have a directory that has image files without extension. Let us say it to be D:initial. Now I want to copy those files over to D:final directory and change the extension to .jpg for each file.



My solution using ROBOCOPY:



@echo off

SET srcDir=D:initial
SET destDir=D:final

echo Copying files from %srcDir%
ROBOCOPY %srcDir% %destDir% /s /min:102400
echo Copying done

cd %destDir%

echo Renaming to JPG
ren *. *.jpg


However, there are certain conditions:




  1. Copy only those files that are greater than 100 KB in size.

  2. Do not delete files in the source directory.

  3. The source directory will at certain periods, get newer files; copy them to the destination directory (manually, no automation needed here)


My solution meets the first two conditions, but when I run again after new files arrive, the older ones get copied over too thus giving error at renaming.







windows cmd.exe file-transfer robocopy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 13 '18 at 7:43









User528491User528491

1033




1033













  • Use the /MAXAGE:n option?

    – DavidPostill
    Jun 13 '18 at 8:13






  • 1





    Your third point says you will do it manually, so where's the problem?

    – Seth
    Jun 13 '18 at 8:13











  • @Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

    – User528491
    Jun 13 '18 at 9:05











  • Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

    – Seth
    Jun 13 '18 at 9:11



















  • Use the /MAXAGE:n option?

    – DavidPostill
    Jun 13 '18 at 8:13






  • 1





    Your third point says you will do it manually, so where's the problem?

    – Seth
    Jun 13 '18 at 8:13











  • @Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

    – User528491
    Jun 13 '18 at 9:05











  • Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

    – Seth
    Jun 13 '18 at 9:11

















Use the /MAXAGE:n option?

– DavidPostill
Jun 13 '18 at 8:13





Use the /MAXAGE:n option?

– DavidPostill
Jun 13 '18 at 8:13




1




1





Your third point says you will do it manually, so where's the problem?

– Seth
Jun 13 '18 at 8:13





Your third point says you will do it manually, so where's the problem?

– Seth
Jun 13 '18 at 8:13













@Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

– User528491
Jun 13 '18 at 9:05





@Seth I meant that the script shouldn't be timed to run periodically; that can be done manually. However, it must account for duplicates.

– User528491
Jun 13 '18 at 9:05













Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

– Seth
Jun 13 '18 at 9:11





Rename files in the source directory and just run robocopy like usual. Robocopy should optimize and skip existing files.

– Seth
Jun 13 '18 at 9:11










2 Answers
2






active

oldest

votes


















2














Check file size and if destination file exists with an iterating for on the sourcefiles.



And use xcopy instead of invoking robocopy every time what would be overkill here.



Copying to the new name with extension in one go eliminates the need to rename.



@echo off

SET "srcDir=D:initial"
SET "destDir=D:final"

echo Copying files from %srcDir%
For %%A in ("%srcDir%*.") do (
if %%~zA gtr 102400 if not exist "%destDir%%%~nA.jpg" copy "%%~fA" "%destDir%%%~nA.jpg" >NUL
)
echo Copying done





share|improve this answer


























  • Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

    – User528491
    Jun 13 '18 at 13:29






  • 1





    Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

    – LotPings
    Jun 13 '18 at 13:34











  • Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

    – User528491
    Jun 13 '18 at 13:45






  • 1





    It's not my day, the modifier was also missing in the check. Please try again.

    – LotPings
    Jun 13 '18 at 13:50






  • 1





    Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

    – LotPings
    Jun 13 '18 at 14:17



















0














xcopy <srcDir> <destDir>.<append>



example
xcopy c:Photos_with no_extensions* c:Jpegs*.jpg



or for you xcopy D:initial* D:final*.jpg



It will copy all the files in the first director to the second and add .jpg to the end. One drawback is it just adds on the new extension i.e. file.pdf would become file.pdf.jpg






share|improve this answer










New contributor




KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fsuperuser.com%2fquestions%2f1330887%2fwindows-copy-files-and-change-extension-without-duplicates%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Check file size and if destination file exists with an iterating for on the sourcefiles.



    And use xcopy instead of invoking robocopy every time what would be overkill here.



    Copying to the new name with extension in one go eliminates the need to rename.



    @echo off

    SET "srcDir=D:initial"
    SET "destDir=D:final"

    echo Copying files from %srcDir%
    For %%A in ("%srcDir%*.") do (
    if %%~zA gtr 102400 if not exist "%destDir%%%~nA.jpg" copy "%%~fA" "%destDir%%%~nA.jpg" >NUL
    )
    echo Copying done





    share|improve this answer


























    • Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

      – User528491
      Jun 13 '18 at 13:29






    • 1





      Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

      – LotPings
      Jun 13 '18 at 13:34











    • Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

      – User528491
      Jun 13 '18 at 13:45






    • 1





      It's not my day, the modifier was also missing in the check. Please try again.

      – LotPings
      Jun 13 '18 at 13:50






    • 1





      Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

      – LotPings
      Jun 13 '18 at 14:17
















    2














    Check file size and if destination file exists with an iterating for on the sourcefiles.



    And use xcopy instead of invoking robocopy every time what would be overkill here.



    Copying to the new name with extension in one go eliminates the need to rename.



    @echo off

    SET "srcDir=D:initial"
    SET "destDir=D:final"

    echo Copying files from %srcDir%
    For %%A in ("%srcDir%*.") do (
    if %%~zA gtr 102400 if not exist "%destDir%%%~nA.jpg" copy "%%~fA" "%destDir%%%~nA.jpg" >NUL
    )
    echo Copying done





    share|improve this answer


























    • Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

      – User528491
      Jun 13 '18 at 13:29






    • 1





      Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

      – LotPings
      Jun 13 '18 at 13:34











    • Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

      – User528491
      Jun 13 '18 at 13:45






    • 1





      It's not my day, the modifier was also missing in the check. Please try again.

      – LotPings
      Jun 13 '18 at 13:50






    • 1





      Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

      – LotPings
      Jun 13 '18 at 14:17














    2












    2








    2







    Check file size and if destination file exists with an iterating for on the sourcefiles.



    And use xcopy instead of invoking robocopy every time what would be overkill here.



    Copying to the new name with extension in one go eliminates the need to rename.



    @echo off

    SET "srcDir=D:initial"
    SET "destDir=D:final"

    echo Copying files from %srcDir%
    For %%A in ("%srcDir%*.") do (
    if %%~zA gtr 102400 if not exist "%destDir%%%~nA.jpg" copy "%%~fA" "%destDir%%%~nA.jpg" >NUL
    )
    echo Copying done





    share|improve this answer















    Check file size and if destination file exists with an iterating for on the sourcefiles.



    And use xcopy instead of invoking robocopy every time what would be overkill here.



    Copying to the new name with extension in one go eliminates the need to rename.



    @echo off

    SET "srcDir=D:initial"
    SET "destDir=D:final"

    echo Copying files from %srcDir%
    For %%A in ("%srcDir%*.") do (
    if %%~zA gtr 102400 if not exist "%destDir%%%~nA.jpg" copy "%%~fA" "%destDir%%%~nA.jpg" >NUL
    )
    echo Copying done






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 13 '18 at 15:15

























    answered Jun 13 '18 at 9:02









    LotPingsLotPings

    5,3061923




    5,3061923













    • Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

      – User528491
      Jun 13 '18 at 13:29






    • 1





      Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

      – LotPings
      Jun 13 '18 at 13:34











    • Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

      – User528491
      Jun 13 '18 at 13:45






    • 1





      It's not my day, the modifier was also missing in the check. Please try again.

      – LotPings
      Jun 13 '18 at 13:50






    • 1





      Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

      – LotPings
      Jun 13 '18 at 14:17



















    • Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

      – User528491
      Jun 13 '18 at 13:29






    • 1





      Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

      – LotPings
      Jun 13 '18 at 13:34











    • Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

      – User528491
      Jun 13 '18 at 13:45






    • 1





      It's not my day, the modifier was also missing in the check. Please try again.

      – LotPings
      Jun 13 '18 at 13:50






    • 1





      Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

      – LotPings
      Jun 13 '18 at 14:17

















    Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

    – User528491
    Jun 13 '18 at 13:29





    Tries to copy D:finalD:initialfile.jpg with the error Does ... specify a file name or directory name on the target?

    – User528491
    Jun 13 '18 at 13:29




    1




    1





    Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

    – LotPings
    Jun 13 '18 at 13:34





    Sorry, forgot to insert the ~n modifier which uses only the name from source file without drive,path.

    – LotPings
    Jun 13 '18 at 13:34













    Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

    – User528491
    Jun 13 '18 at 13:45





    Works well, but now it ask confirmation every time if the target is a file or directory. Also, when I run again, it asks if I want to overwrite for all files (which is no)

    – User528491
    Jun 13 '18 at 13:45




    1




    1





    It's not my day, the modifier was also missing in the check. Please try again.

    – LotPings
    Jun 13 '18 at 13:50





    It's not my day, the modifier was also missing in the check. Please try again.

    – LotPings
    Jun 13 '18 at 13:50




    1




    1





    Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

    – LotPings
    Jun 13 '18 at 14:17





    Let's take copy without x and we should be good. To suppress the message 1 file(s) copied apppend >NUL to the copy

    – LotPings
    Jun 13 '18 at 14:17













    0














    xcopy <srcDir> <destDir>.<append>



    example
    xcopy c:Photos_with no_extensions* c:Jpegs*.jpg



    or for you xcopy D:initial* D:final*.jpg



    It will copy all the files in the first director to the second and add .jpg to the end. One drawback is it just adds on the new extension i.e. file.pdf would become file.pdf.jpg






    share|improve this answer










    New contributor




    KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      xcopy <srcDir> <destDir>.<append>



      example
      xcopy c:Photos_with no_extensions* c:Jpegs*.jpg



      or for you xcopy D:initial* D:final*.jpg



      It will copy all the files in the first director to the second and add .jpg to the end. One drawback is it just adds on the new extension i.e. file.pdf would become file.pdf.jpg






      share|improve this answer










      New contributor




      KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        xcopy <srcDir> <destDir>.<append>



        example
        xcopy c:Photos_with no_extensions* c:Jpegs*.jpg



        or for you xcopy D:initial* D:final*.jpg



        It will copy all the files in the first director to the second and add .jpg to the end. One drawback is it just adds on the new extension i.e. file.pdf would become file.pdf.jpg






        share|improve this answer










        New contributor




        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        xcopy <srcDir> <destDir>.<append>



        example
        xcopy c:Photos_with no_extensions* c:Jpegs*.jpg



        or for you xcopy D:initial* D:final*.jpg



        It will copy all the files in the first director to the second and add .jpg to the end. One drawback is it just adds on the new extension i.e. file.pdf would become file.pdf.jpg







        share|improve this answer










        New contributor




        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited 17 hours ago





















        New contributor




        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 18 hours ago









        KAROL SITHKAROL SITH

        11




        11




        New contributor




        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        KAROL SITH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1330887%2fwindows-copy-files-and-change-extension-without-duplicates%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

            Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

            looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...