1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

help with simple batch file

Discussion in 'General Software' started by djmonson, Jun 26, 2007.

  1. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    i want to create a batch file that will:
    move files from 'directory1' to 'directory2'
    if (and only if) the file DOES NOT begin with an underscore

    anyone know how to do this??

    David
     
  2. FOXCONN1115 New Member

    Joined:
    Mar 30, 2007
    Messages:
    398 (0.11/day)
    Thanks Received:
    8
    Location:
    Rhode Island, USA
    umm..? what are you trying to do? copy directories? basic is a good language for things like this. IF/THEN statements rule. :D
     
    10 Year Member at TPU
  3. Random Murderer

    Random Murderer The Anti-Midas

    Joined:
    Dec 6, 2006
    Messages:
    6,988 (1.84/day)
    Thanks Received:
    1,903
    Location:
    Florida, A.K.A. the Sweatbox
    yes, but batch files are easier to create within dos, and i think that's what he's trying to do.
     
    10 Year Member at TPU
  4. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    sorry if i wasn't specific enough. and i don't need it to be a batch file necessarily.

    i want an automated way to move files from one folder to another (both on the C drive)
    but i want it to move all mp3 files EXCEPT for the ones that begin with an underscore
     
  5. FOXCONN1115 New Member

    Joined:
    Mar 30, 2007
    Messages:
    398 (0.11/day)
    Thanks Received:
    8
    Location:
    Rhode Island, USA
    i've found that the easiest way to copy things is to do an advanced search and type in *.mp3 and then just choose whatever files you want, easiest by sorting by name, then copy..
     
    10 Year Member at TPU
  6. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    can't that be made into an automated process? i do the action you recommended many times over, and i was hoping that somehow i could create a file that, when double-clicked, would just move the files from that location to another (but not if they start with an underscore, like i mentioned)
     
  7. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,480 (2.22/day)
    Thanks Received:
    1,382
    So basically you want to move finished downloads to some other folder and temp files start with an underscore? Just a guess.
     
    10 Year Member at TPU
  8. ex_reven New Member

    Joined:
    Sep 4, 2006
    Messages:
    5,217 (1.34/day)
    Thanks Received:
    171
    Moving porn ay :roll:
     
    10 Year Member at TPU
  9. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,480 (2.22/day)
    Thanks Received:
    1,382
    Trafficking
     
    10 Year Member at TPU
  10. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    no, perverts. mp3's. music not porn :eek:

    any ideas?
     
  11. Ehstii New Member

    Joined:
    Jun 19, 2007
    Messages:
    607 (0.17/day)
    Thanks Received:
    34
    Location:
    The Shore, New Jersey
    copy and paste this into notepad, and save as .bat



    example:

    @echo off
    xcopy /c /d /f /k /s /y "c:\my music" e:\music



    just replace it with the correct locations.

    and when you run the batch file it will ask you if you want to copy the the file, or the directory. just type "D" for directory and your good to go.
     
    Last edited: Jun 26, 2007
  12. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    does the "/c /d /f /k /s /y" section act like an "if statement"? or what is that code for?
     
  13. Ehstii New Member

    Joined:
    Jun 19, 2007
    Messages:
    607 (0.17/day)
    Thanks Received:
    34
    Location:
    The Shore, New Jersey
    xcopy is DOS.
    its xcopy commands...

    /c = Continues copying even if errors occur.
    /d = Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
    /f = Displays full source and destination file names while copying.
    /k = Copies attributes. Normal Xcopy will reset read-only attributes.
    /s = Copies directories and subdirectories except empty ones.
    /y = Suppresses prompting to confirm you want to overwrite an existing destination file.


    its easy and simple. i use it all the time to back up all the stuff on my hard drive to my external.
     
    djmonson says thanks.
  14. Ehstii New Member

    Joined:
    Jun 19, 2007
    Messages:
    607 (0.17/day)
    Thanks Received:
    34
    Location:
    The Shore, New Jersey
    did this help you out?bump.
     
  15. djmonson New Member

    Joined:
    Jun 17, 2007
    Messages:
    15 (0.00/day)
    Thanks Received:
    0
    yes thanks much
     
  16. Ehstii New Member

    Joined:
    Jun 19, 2007
    Messages:
    607 (0.17/day)
    Thanks Received:
    34
    Location:
    The Shore, New Jersey
    no problem, enjoy.
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)