Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file help  (Read 10149 times)

0 Members and 1 Guest are viewing this topic.

acidblue

    Topic Starter


    Rookie

    Re: Batch file help
    « Reply #15 on: July 29, 2010, 01:59:28 PM »
    BTW what would be the right syntax for copying different file types.
    Right now I have this:

    Code: [Select]
    xcopy /s "%userprofile%\my documents\*.jpg\*.txt\*.gif\*.bmp" "c:\temp2" /Y
    pause

    But it kicks "File not found error.

    southpaw63119



      Beginner
    • Thanked: 3
      • Yes
      • Yes
    • Experience: Experienced
    • OS: Linux variant
    Re: Batch file help
    « Reply #16 on: July 29, 2010, 02:06:55 PM »
    Code: [Select]
    xcopy "c:\Documents And Settings\%userprofile%\my documents\*.jpg" c:\temp2\*.*  /S /Y
    xcopy "c:\Documents And Settings\%userprofile%\my documents\*.txt" c:\temp2\*.*  /S /Y
    xcopy "c:\Documents And Settings\%userprofile%\my documents\*.gif" c:\temp2\*.*  /S /Y
    xcopy "c:\Documents And Settings\%userprofile%\my documents\*.bmp" c:\temp2\*.*  /S /Y

    That should probably work.
    There is an exclude switch, but it's probably more efficient in this case to split it into multiple lines...
    (I would leave "@echo off" out and "PAUSE" in the code until you have it working properly).
    This is why we can't have nice things.

    Salmon Trout

    • Guest
    Re: Batch file help
    « Reply #17 on: July 29, 2010, 02:16:19 PM »
    Have to run - dishes to wash, shower to take, TV show to watch, whiskey (Irish hence spelling) to pour into shot glass - xcopy only allows 1 filespec at a time - suggested solutions

    1. have 1 xcopy command for each filetype

    xcopy sourcefolder\*.jpg destinationfolder /switches
    xcopy sourcefolder\*.doc destinationfolder /switches
    etc

    [EDIT - I see this has been covered]

    2. use the FOR command to parse a list of filetypes and substitute each one in turn into the command

    Code: [Select]
    for %%T in (jpg png) do xcopy "s:\test\pixcopy\*.%%T" "s:\test\pixcopy2" /Y
    Note longer form of FOR with brackets

    Code: [Select]
    for %%T in (jpg png) do (
        xcopy "s:\test\pixcopy\*.%%T" "s:\test\pixcopy2" /Y
        )