Bat Script Thingy

Happyman7

New member
Local time
12:40 AM
Messages
9
Hi,

I was wondering if someone could tell me how to do some commands (in order) so I can just plug in a Flash Drive with the bat file on it and double click on it. Double clicking on it would launch it and cause it to grab files off the computer it is plugged into (they're my files) and transfer them to the flash drive. I don't know what the drive letter of the flash drive is, as it is different between computers.

So here is what I want it to do:

1. Move all the files/folders in the folder to a zip file
2. Take that zip file and move it to the flash drive. The drive letter won't be known.

Please tell me how to do this so I can *quickly* get the files and move on.

Thanks

-Happyman7
 

My Computer

Computer Manufacturer/Model Number
Toshiba
OS
Windows 7 Home Premium
CPU
Core 2 Duo
Graphics Card(s)
128 MB (I think)
Other Info
It's a laptop :D
The command line utility to copy files and directory trees is:

XCOPY [SOURCE] [DESTINATION]

i.e.

XCOPY C:\...\ParentFolderName D:\DestinationFolder

This will copy all of the files and folders within the source folder to the destination folder.

You can assign your flash drive to a specific drive letter through disk management. This will only help if you're doing this on the same computers over and over.

Disk Management:
Start > Search "computer management" > Enter > Click on Disk Management > Right Click Drive in Question > Assign Letters & Paths > Assign a specific letter.

To compress the files you'll probably need a third party program like WinZip, PKZip or EasyZip with a command line function.

For Winzip:http://www.winzip.com/prodpagecl.htm

Command Line Utilities accessible via .BAT file:
http://www.memecode.com/docs/winzip.html

In other words your .BAT file might look something like this if you flash drive was locked to F:

winzip32 -min -a -r -es F:\zipfilename.zip %USERPROFILE%\Downloads\Files\

Note: -min = Minimized, -a = Add, -r = Include Subfolders, -es = Super Fast Compression

If i've done that correctly, that should place all of the files located in C:\Users\yourusername\Downloads\Files\ in a zip file named zipfilename.zip located in drive F:

To extract the files at a different computer with the flash drive locked to F:

winzip32 -e -o F:\zipfilename.zip %USERPROFILE%\Downloads\DestinationFolder\

Note: -e = Extract, -o = Overwrite

That should move the files from the zip file on drive F: to a folder called DestinationFolder in C:\Users\yourusername\Downloads
 

My Computer

Computer Manufacturer/Model Number
Apple Macbook Pro (April 2009)
OS
W7 Ult. x64 | OS X
CPU
Intel Mobile Core 2 Duo 2.93Ghz [T9800 Penryn]
Motherboard
NVIDIA nForce 730i Rev. B1 [Mac-F2268EC8 (U2E1)]
Memory
4096MB Samsung DDR3 Dual Channel [PC3-8500F 1066Mhz]
Graphics Card(s)
NVIDIA GeForce 9600M GT 512MB [G96M Rev. C1]
Sound Card
SB X-Fi Surround 5.1 USB | Onboard Realtek (Disabled)
Monitor(s) Displays
Acer x223wbd 22" | Apple Anti-Glare 17" (Disabled)
Screen Resolution
{Current} 1440x900 {Acer} 1680x1050 {Apple} 1920x1200
Hard Drives
{Internal}
Seagate Momentus 320GB 2.5" 7200RPM [ST9320421AS]

{Externals}
LaCie 320GB USB 2.0 HDD [301284UR]
LaCie 750GB USB 2.0 FW400 eSATA HDD [301314U]
LaCie 1TB USB 2.0 HDD [301304UR]
PSU
Magsafe
Case
Aluminum/Unibody (MBP52)
Cooling
2 x 6000 RPM Fans
Keyboard
Logitech G-15v2 [PN 920-000379]
Mouse
Logitech G-9 [PN 910-000338]
Internet Speed
12Mbps/2.5Mbps w/ 24Mbps Speed Boost [Comcast]
Other Info
Logitech X-540 Speakers [PN 970223-0122]
Sennheiser PC-151 Headset
I can't exactly get into any settings because it is a public/educational computer. So can't it find itself the Drive letter? Also, I want to try and avoid installing any applications. :P I forgot to mention that the computer the bat file runs on is running Windows XP. (It's the most stable for public use :P)
 

My Computer

Computer Manufacturer/Model Number
Toshiba
OS
Windows 7 Home Premium
CPU
Core 2 Duo
Graphics Card(s)
128 MB (I think)
Other Info
It's a laptop :D
I cant exactly help with ziping as i dont know the commands for that. I have a batch file i use to copy a avi files from folders and copy them in to a new folder called newTV_2010-04-28.( i use the year month day as it sorts better when put in a list) I run the batch file from the removable drive which can have different letter each time but the source files are always in the same location.

here is the code i use
---------------------
MD newTV_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
cd \newTV_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
xcopy l:\1monday\*.avi
xcopy l:\2tuesday\*.avi
xcopy l:\3wednesday\*.avi
xcopy l:\4thursday\*.avi
xcopy l:\5friday\*.avi
xcopy l:\6saturday\*.avi
xcopy l:\7sunday\*.avi
Pause
-------------------------------

MD newTV_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
this line creates a new folder called newTV with the current date added (date is in the format of year-mm-dd) change the newTV_ to name of your choice

cd \newTV_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
this line moves program focus into the newly created folder

xcopy l:\1monday\*.avi
xcopy l:\2tuesday\*.avi
xcopy l:\3wednesday\*.avi
xcopy l:\4thursday\*.avi
xcopy l:\5friday\*.avi
xcopy l:\6saturday\*.avi
xcopy l:\7sunday\*.avi
these lines copy all avi files from the source locations, you could simply change that to xcopy "your files location\*.*" to copy allfiles from chosen location to the new directory.

Pause
i genrally like to leave a pause command in so that i can look over what has been done but if you leave it out it is not a problem

i called the file weeklycopy.bat and it simply sits on the root of the storage device

an example of code you could use would be

-------------------------------------
MD new_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
cd \new_%Date:~-4,4%-%Date:~-7,2%-%Date:~-10,2%
xcopy l:\1monday /e
pause
---------------------------------------

what this code would do is create a new folder on your flash drive called new_2010-04-28
and copy all the contents of the selected folder to the new folder.

simply change l:1monday to the folder you want to copy and remember if the any part of the folder path has a space put " at each end eg you would use xcopy "c:\my stuff" /e instead of xcopy c:\my stuff /e as spaces will cause it fail unless " marks are used at each end.



Hope this will help.
 
Last edited:

My Computer

OS
Windows 7 Pro
Back
Top