need bat file to copy files from flash drive to my documents on multiople computers

Discussion in 'Software' started by red death68, Nov 4, 2009.

  1. red death68

    red death68 Command Sergeant Major

    i need a bat file to copy a folder and all of its contents from a flash drive to my documents on multiple computers so i can keep an updated back up of an ongoing project i can then run it with the autorun ini so it will auto run when i plug it in any help

    also if possible can you add a yes or no function to it for certain computers i might not want it on like friends computers?

    tyvm in advance for any help and i will say in advance thank you germanone since you respond to all batch file questions as far as iv seen = D
     
  2. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    Hi red death68,

    hope that will help:
    Code:
    @echo off &setlocal
    set /p "answer=Do you want to copy? [y/n] "
    if /i "%answer%" neq "y" goto :eof
    for /f "tokens=2* delims=	" %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"^|findstr /i /c:"Personal	"') do set "Personal=%%b"
    md "%Personal%\yourFolder"
    xcopy "%~d0\yourPath\yourFolder" "%Personal%\yourFolder" /c /q /i /e /y
    
    Regards
    GermanOne
     
  3. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    one question what am i replacing

    and tyvm i figured youd be the one to respond rofl wish i could create batches like you
     
  4. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    Hi red death68,

    "yourFolder" is the folder name what you want to copy,
    "yourPath" is the path to "yourFolder" on your flash drive (without drive letter).
    You also could try the xcopy line without %~d0 (remember: absolute or relative path - we talked about).

    regards
    GermanOne
     
  5. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    i must have done somthing wrong i cant get it to work

    the folder to copy is called english
    the path is the main drive itself right after you double click the drives icon
    and do i need to set a path where to copy? if so i want it to go to
    C:\Documents and Settings\Compaq_Owner\Desktop
     
  6. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    O/K. In your first post you wrote that you want to copy to "my documents".
    So if you want it to the desktop, it will be easier.
    Code:
    @echo off &setlocal
    set /p "answer=Do you want to copy? [y/n] "
    if /i "%answer%" neq "y" goto :eof
    md "%userprofile%\Desktop\yourFolder"
    xcopy "%~d0\yourPath\yourFolder" "%userprofile%\Desktop\yourFolder" /c /q /i /e /y
    
    regards
    GermanOne
     
  7. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    it says the folder already exists how can i make it recopy the files and over write the old ones?
     
  8. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    I think this message is from the MD command because the folder on your desktop still exists if you start the batch the second time. So what we could do is remove this folder using RD and then make a blank new one using MD.

    Code:
    @echo off &setlocal
    set /p "answer=Do you want to copy? [y/n] "
    if /i "%answer%" neq "y" goto :eof
    if exist "%userprofile%\Desktop\yourFolder" rd /s /q "%userprofile%\Desktop\yourFolder"
    md "%userprofile%\Desktop\yourFolder"
    xcopy "%~d0\yourPath\yourFolder" "%userprofile%\Desktop\yourFolder" /c /q /i /e /y
    
    regards
    GermanOne
     
  9. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    works like a charm thank you for all the help again...
     
  10. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    No problem. Batch is a hobby and if I can help, at least it's useful.

    regards
    GermanOne
     
  11. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    lol wish i could learn it like you have
    how did you learn so much about it? is there a book or somthing i can look for
     
  12. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    Oh, as you know I'm from Germany. There are good german tutorials and german forums for batch. I'm sure the same will exist in English, but I don't know. :(
     
  13. red death68

    red death68 Command Sergeant Major

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    o so basicly google like mad with your fingers and toes crossed rofl
     
  14. GermanOne

    GermanOne Guest

    Re: need bat file to copy files from flash drive to my documents on multiople compute

    Well, it's not only google. I've learned the basics by myself just using the HELP command.

    Open a DOS box and write HELP, push ENTER and you will get all the basic commands with a short description. For detailed help for a single command write [command] /? e.g.
    FOR /?

    Write SET, push ENTER and you will get all environment variables you can use.

    More is not needed for all your batches until now.
     
  15. rosendinho

    rosendinho Private E-2

    Re: need bat file

    hello GermanOne,
    i could not help but notice that you understand a lot about batch files. I for one dont understand much about it. iam trying to create a batch file to help user's in an install of a new application software. not all users have the application, for licensing make sure to only install those users that have the software. the replacement software needs to be located in the same path as the original to maintain continuity. The old software is in C:\apps\newapp. There are two files that will need to remain in the install directory for its reporting features to fuction. Those files will be name.ini and location.ini . Check to see if they are there, replace them if they are not. There are good copies on the N:\apps\ini folder. The new install folder is on ther server at N:\newstuff\apps\ . All of the files located in that directory will need to be in the new install. Maintain the local copy of the old intall directory and all of its contents. There should be little or no user interaction. Except to notify them when the install is complete.

    there it is GermanOne, i truly hope you can figure this out because i really cant have tried my best. thank you in adavance
     
    Last edited by a moderator: Nov 30, 2009
  16. SWario

    SWario Sergeant

    Re: need bat file

    Please make your own thread about your own issue. Feel free to link to other threads, but jumping onto someone else's thread is not good (n)etiquette.
     
  17. GermanOne

    GermanOne Guest

    Re: need bat file

    Hello rosendinho,

    I'm not a programmer and I'm not sure if I understood all what you want to do.
    How ever, look to the REM lines to see what the next step will make. Hope you could use something from the following.
    Code:
    @echo off &setlocal &title Install New Version & color 90 &mode con cols=50 lines=10
    
    REM look for app.exe to make sure the old version is still installed
    if not exist "C:\apps\newapp\app.exe" (
      echo.
      echo  You don't have a license for this software.
      echo.
      pause>nul|set /p "=Press any key to close the window ... "
      goto :eof
    ) else (
      echo.
      echo Please wait ...
      echo.  
    )
    
    REM make a new "old" folder for maintaining the former version
    md "C:\apps\old" 2>nul
    
    REM move the whole "newapp" to "old"
    move "C:\apps\newapp" "C:\apps\old\newapp" >nul
    
    REM copy the new from N:
    xcopy "N:\newstuff\apps\newapp" "C:\apps\" /c /q /i /e /y >nul
    
    REM figure out if the *.ini files are in "old"
    REM case yes - copy from old, else - copy from N:
    if exist "C:\apps\old\newapp\name.ini" (
      copy "C:\apps\old\newapp\name.ini" "C:\apps\newapp\name.ini" >nul
    ) else (
      copy "N:\apps\ini\name.ini" "C:\apps\newapp\name.ini" >nul
    )
    
    if exist "C:\apps\old\newapp\location.ini" (
      copy "C:\apps\old\newapp\location.ini" "C:\apps\newapp\location.ini" >nul
    ) else (
      copy "N:\apps\ini\location.ini" "C:\apps\newapp\location.ini" >nul
    )
    
    REM give the finished masage
    cls
    echo.
    echo  The installation is complete.
    echo.
    pause>nul|set /p "=Press any key to close the window ... "
    
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds