Who can help with easy script for copying files from list in Windows?

Discussion in 'Scripting' started by accw, Jun 28, 2016.

  1. accw

    accw MDL Novice

    Jun 28, 2016
    5
    1
    0
    Dear all,

    Who can help me create a simple script (I guess it is realy simple, but I do not know where to start) which will help me make life more easy :)

    Background:
    I am photographing a lot as hobby and especially when I make pictures from nature I let my camera store the files in two separate formats. One format is "JPG" and the other is a raw format called "NEF".
    In my selecting process I rate my JPG pictures so I know which I want to preserve and to adjust.
    The thing is, is that I want te corresponding NEF files from the selected JPG files.

    Script functionality:
    What I want the script to do is:
    Copy the corresponding* NEF files in c:\temp2 to c:\dest1
    The correspsonding files are the JPF files in C:\temp1

    STEPS???
    1. In think it would be easy to create a list with files names in C:\temp1
    2. remove the JPG extension
    3. Copy files from list (with NEF extension) from C:\temp2 to c:\dest1

    Who can help me?
    Thanx in advance
     
  2. accw

    accw MDL Novice

    Jun 28, 2016
    5
    1
    0
    to be clear:

    start situation:
    C:\TEMP1\
    A.jpg
    B.JPG
    E.jpg

    C:\TEMP2\
    A.NEF
    B.NEF
    C.NEF
    D.NEF
    E.NEF
    F.NEF

    Desired Result:
    C:\DEST1\
    A.NEF
    B.NEF
    E.NEF
     
  3. accw

    accw MDL Novice

    Jun 28, 2016
    5
    1
    0
    Thanx for the help :p

    figured it out myself how to do it.
    maybe not the most neat one, but this does the trick.
    (starting from TEMP and not root)

    SCRIPT
    set src_folder=I:\temp\temp2
    set dst_folder=I:\temp\dest1

    md i:\temp\tempx
    Copy i:\temp\temp1\*.* i:\temp\tempx\*.nef
    Dir I:\temp\tempx\*.nef /B > i:\temp\jpglist.txt
    for /f "tokens=*" %%i in (i:\temp\jpglist.txt) DO (copy "%src_folder%\%%i" "%dst_folder%")

    del /Q i:\temp\tempx\*.*
    rd i:\temp\tempx
    del i:\temp\jpglist.txt
    SCRIPT END
     
  4. Compo

    Compo MDL Member

    Mar 29, 2011
    136
    106
    10
    #4 Compo, Jun 28, 2016
    Last edited by a moderator: Apr 20, 2017
    Congratulations on finding a solution, here's a simplified version for you
    Code:
    @Echo Off
    SetLocal
    Set "jSrc=I:\temp\temp1"
    Set "nSrc=I:\temp\temp2"
    Set "nDst=I:\temp\dest1"
    For %%a In ("%jSrc%\*.jpg") Do (
    If Exist "%nSrc%\%%~na.nef" Copy "%nSrc%\%%~na.nef" "%nDst%")
     
  5. LiteOS

    LiteOS Windowizer

    Mar 7, 2014
    2,204
    978
    90
    Would u like powershell script ?
     
  6. accw

    accw MDL Novice

    Jun 28, 2016
    5
    1
    0
    Hi Compo,

    Thanx a lot.
    This is truely helpfull.
    I will try this one out soon! (I hate to do an extra copy and rename files to a incorrect format :)
    yours is so much better

    grt,
    Alex
     
  7. accw

    accw MDL Novice

    Jun 28, 2016
    5
    1
    0
    Hi lite8,

    Thanx for the offer. Batch will works fine for me.
    What would be the benefit of powershell?

    grt,
    Alex