Step 3: Make the file for copy of documents to drive
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
Remove these ads by
Signing Up





































Visit Our Store »
Go Pro Today »




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
":: 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
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.
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.
like documents, videos, picture, and favorites
%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