0

How would someone write a program that when one plugs in an USB, it would auto run, find file names and copy them onto the USB? I have tried it several times with varying degrees of success but never full.

0

you can create an autorun file which this code is in there to copy files from the PC.

%backupcmd% "%USERPROFILE%\pictures" "%drive%\all\My pics"

So if you switched the two codes in quotes it'll copy files from the USB. Like So.

%backupcmd% "%drive%\all\My pics" "%USERPROFILE%\pictures"

or you can try:

@echo on :: variables SET odrive=%odrive:~0,2% set backupcmd=xcopy /s /c /d /e /h /i /r /y echo on %backupcmd% "%USERPROFILE%\Favorites" "%drive%\backup\favorites" %backupcmd% "%USERPROFILE%\Desktop*.jpg" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\Desktop*.jpeg" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\Desktop*.bmp" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\Desktop*.3gp" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\Desktop*.mp4" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\Desktop*.avi" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\Desktop*.wmv" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\Contacts" "%drive%\backup\contacts" %backupcmd% "%USERPROFILE%\Links" "%drive%\backup\links" %backupcmd% "%USERPROFILE%\My Documents\My Music" "%drive%\backup\mp3" %backupcmd% "%USERPROFILE%\My Documents\Downloads" "%drive%\backup\downloads" %backupcmd% "%USERPROFILE%\My Music" "%drive%\backup\mp3" %backupcmd% "%USERPROFILE%\My Documents*.jpg" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\My Documents*.bmp" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\My Documents*.avi" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\My Documents*.mpg" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\My Documents*.3gp" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\My Documents*.mp4" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\My Pictures" "%drive%\backup\img" %backupcmd% "%USERPROFILE%\Videos" "%drive%\backup\vid" %backupcmd% "%USERPROFILE%\Music" "%drive%\backup\mp3" %backupcmd% "%USERPROFILE%\Downloads" "%drive%\backup\downloads" %backupcmd% "D:.jpg" "%drive%\backup\img" %backupcmd% "D:.jpeg" "%drive%\backup\img" %backupcmd% "D:.bmp" "%drive%\backup\img" %backupcmd% "D:.3gp" "%drive%\backup\vid" %backupcmd% "D:.mp4" "%drive%\backup\vid" %backupcmd% "D:.avi" "%drive%\backup\vid" %backupcmd% "D:*.wmv" "%drive%\backup\vid" @echo on cls

  • So this will copy everything from the music, downloads, documents, pictures, and everything?>!? – J. Doe Aug 7 '15 at 4:04
  • like literally everything – J. Doe Aug 7 '15 at 4:05
  • you can edit it and replace with the files you need to be copied. use it as template – Botmaster Aug 7 '15 at 6:15
  • @Botmaster Please read superuser.com/editing-help#code, and edit your answer, formatting the code so it is 1) easy to read, 2) easier for others to copy and re-use. – DavidPostill Aug 7 '15 at 8:13
  • ok sorry for that. am new :) – Botmaster Aug 7 '15 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.