Auto Duplicate file X Times ?

Page 3 of 4 FirstFirst 1234 LastLast

  1. Posts : 10
    Windows 10
       #21

    Bree said:
    This .bat was written to meet the the needs of the OP, specifically to make multiple copies of one file. Your needs are different, and this .bat doesn't meet them. Rather than adapting it, you should start from scratch, maybe using some of the techniques learned from my examples.

    Writing a batch file is as much an exercise in programming as is writing the C++ code to compile into a program. First you should write down in simple language the steps you want it to take, and what steps it should take should certain conditions occur (eg, a pre-existing file name). Write it as a simple set of instructions a person could follow manually, without needing much in-depth understanding. Then take those simple instructions and translate them into an appropriate sequence of commands to put in a batch file.

    The key to writing an effective batch file is to have a clear idea of what you want it to do and how it should cope with unexpected situations before you start writing the actual commands.




    I don't have a clear idea of what you want, so can't really suggest suitable changes. You may well find that just by taking a step back and trying to explain in simple language the steps you want to achieve, then the way to do it would become clear.
    Thank you for those words of wisdom, i took you're advice and went back to the drawing board. I've learned from you're code. im a hands-on kind of coder. i like to test and see results. This is what i ended up doing. this is for a project to use a Decompiler to then rename/move and delete. i am always willing to learn.Auto Duplicate file X Times ?-code.png
      My Computer


  2. Posts : 24,643
    10 Home x64 (21H2) (10 Pro on 2nd pc)
       #22

    Mizzy said:
    Thank you for those words of wisdom, i took you're advice and went back to the drawing board. .... i am always willing to learn.
    Looks like you are doing well, nice use of date/time there.
      My Computers


  3. Posts : 197
    Windows 10 Home
    Thread Starter
       #23

    Ztruker said:
    My curiosity is peaked! @OtherWay1982, can you tell me why you need (or want) to do this?
    basically there is a image file that works with a ini settings file, in a specific software.
    cant really remember totally because i had a computer wipe. seemed to have wiped my brain about this along with it :)
    but i think it was to make a copy of this ini file. all i needed to do is rename that file to the corresponding image that goes with it and it works. I dont totally recall. but because i have to do this again im trying to look up old threads to get the two bat files i had. so far i kinda found one but missing the others. the main file for this was on stackoverflow website my account there. but they since removed my account so that information is lost so far.
      My Computer


  4. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
       #24

    Okay, thank you.
      My Computers


  5. Posts : 1
    WinXP
       #25

    Wooo!


    Bree said:
    Yes. That is a relatively easy change to make. Use MultiCopy2.bat (attached in a .zip). Drop the extracted .bat into the folder where you want to make duplicates and run it, you'll be asked for a file name and the number of copies. This one can cope with spaces in the file name.


    Well, normally I'd say just ask away, but this could grow into a very long thread that way

    I Googled for a CMD guide for you, there are many out there, but most are not very good. The link I gave at the bottom of post #7 is the best one I found, if you wish to learn more.
    Created an account just to download this. It works as intended!

    Mizzy said:
    I ran the bat in CMD but for some reason i can't get it to run, what line do i edit?
    Attachment 273207
    Thank you so much V2 Bat works great but i want them to go in another folder after copy, and instead of copy could it be possible to just move/rename? isnt that mv?

    EDIT:
    Attachment 273209
    I figured out what you meant, i just wanted it to copy only that file. is it possible to add a break and then copy another file name at the same time? and is it possible to automatically rename, lets say i already have Copy 1 and i run the Bat again, and i make 1 copy it would replace, i want it not to replace but rename. i've been messing around this some commands but i can't seem to get what i want.

    - - - Updated - - -

    I figured some of it out, i think im getting the hang of this.Attachment 273218
    I still trying to find out how to load and copy both files at once, so i just run the bat and it automatically copies and renames both files once. i know this was intended for copying a single file multiple times and this led me to the right track. i might be over thinking this and it might be simple. lol
    There's a program called Bulk Rename Utility that does what you want. I use it when I need to batch rename more than one file at once without needing to manually rename them one by one unless those names are unique per file in which case this program won't help... What it didn't have was being able to copy one file and then specify how many times and where to save them. Went on the interwebs and found this thread, even though it doesn't let you specify directory save location of the duplicated files, having them saved in the same folder as the file you want to copy, it does the other bit I need well - just need to manually move those duplicated files....
      My Computer


  6. Posts : 1
    Windows 10 Professional
       #26

    Bree said:
    Yes. That is a relatively easy change to make. Use MultiCopy2.bat (attached in a .zip). Drop the extracted .bat into the folder where you want to make duplicates and run it, you'll be asked for a file name and the number of copies. This one can cope with spaces in the file name.


    Well, normally I'd say just ask away, but this could grow into a very long thread that way

    I Googled for a CMD guide for you, there are many out there, but most are not very good. The link I gave at the bottom of post #7 is the best one I found, if you wish to learn more.
    I edited the multicopy2.bat file to number the copies at the right end, just before the extension. I've attached multicopy3.bat to this post.
    Auto Duplicate file X Times ? Attached Files
      My Computer


  7. Posts : 1
    Windows 10
       #27

    Could I also get the zip file for the MultiCopy2.bat pls I also need it to make duplicates of the same file
      My Computer


  8. Posts : 958
    Microsoft Windows 10 Home
       #28

    Since this bubbled up, here's a PowerShell version:


    Code:
    Function MultiCopy {
        [CmdletBinding()]
        Param
        (
            [String[]] [Parameter(Mandatory=$true, ValueFromPipeline=$true)] $Path ,
            [Int]      [Parameter()] $Count = 10 ,
            [String]   [Parameter()] $Format = '{0} (Copy {1}){2}' 
        )
        Process
        {
            ForEach ( $file in @(Get-Item($Path)) ) {
                For ( $i=1 ; $i -le $Count ; $i++ ) {
                    Copy-Item $File ( $Format -f $file.BaseName, $i, $file.Extension )
    }   }   }   }
      My Computer


  9. Posts : 2
    Windows 10 Pro
       #29

    Bree said:
    Here's a basic one to do the job. Copy all the code below, paste it into Notepad and save as MultiCopy.bat.

    Note that only basic 'sanity checks' are made, so it pauses after each copy to give you a chance to Ctrl-C out of an infinite loop. Also, the text '(Copy n) ' is added at the beginning of the filename, not the end (which would have added it to the file type extension). It would take some complicated parsing to find the extension in the filename and inset the copy count there.

    Code:
    @echo off
    echo.
    if NOT "%2"=="" goto next1
    
    echo %0 will make the specified number of copies of a file to (by default) the current folder
    echo The copies will have '(Copy n) ' added at the beginning of the filename, where 'n' is the count
    echo .
    echo Useage: %0 copies source_file [destination folder]
    echo example: %0 10 test.txt C:\temp
    goto end
    
    :next1
    if EXIST ".\%2" goto next2
    echo file %2 not found
    goto end
    
    :next2
    set count=%1
    set destination=%3
    if "%3"=="" set destination=.
    
    :repeat
    @echo on
    copy %2 "%destination%\(Copy %count%) %2"
    @echo off
    pause
    
    set /a count=%count%-1 
    if %count% LEQ 0 echo Requested number of copies (%1) have been made.
    if %count% LEQ 0 goto end
    
    goto repeat
    
    :end
    I love this batch file. Is there a way that I can make sure that the number is always at least a 2 digit number? I've tried various things, but admittedly don't really know what I am doing.
      My Computer


  10. Posts : 24,643
    10 Home x64 (21H2) (10 Pro on 2nd pc)
       #30

    Tayl0124 said:
    I love this batch file. Is there a way that I can make sure that the number is always at least a 2 digit number? I've tried various things, but admittedly don't really know what I am doing.

    Welcome to Ten Forums.

    Glad you like it. I have added a prefix to the count in the copy's filename that is initially empty, but will be set to 0 if the count is 9 or less. As the count is running down from your specified number, when it reaches 9 the filename will say '(Copy 09)' now.

    Code:
    @echo off
    echo.
    if NOT "%2"=="" goto next1
    
    echo %0 will make the specified number of copies of a file to (by default) the current folder
    echo The copies will have '(Copy n) ' added at the beginning of the filename, where 'n' is the count
    echo .
    echo Useage: %0 copies source_file [destination folder]
    echo example: %0 10 test.txt C:\temp
    goto end
    
    :next1
    if EXIST ".\%2" goto next2
    echo file %2 not found
    goto end
    
    :next2
    set count=%1
    set destination=%3
    if "%3"=="" set destination=.
    set prefix=
    
    :repeat
    if %count% LEQ 9 set prefix=0
    @echo on
    copy %2 "%destination%\(Copy %prefix%%count%) %2"
    @echo off
    pause
    
    set /a count=%count%-1 
    if %count% LEQ 0 echo Requested number of copies (%1) have been made.
    if %count% LEQ 0 goto end
    
    goto repeat
    
    :end
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 10:03.
Find Us




Windows 10 Forums