Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Bat Script Thingy

27 Apr 2010   #1

Windows 7 Home Premium
Bat Script Thingy


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.



My System SpecsSystem Spec
27 Apr 2010   #2
not so gray matter

W7 Ult. x64 | OS X

The command line utility to copy files and directory trees is:



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:

Command Line Utilities accessible via .BAT file:

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:\ %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 located in drive F:

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

winzip32 -e -o F:\ %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 System SpecsSystem Spec
27 Apr 2010   #3

Windows 7 Home Premium

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 System SpecsSystem Spec

28 Apr 2010   #4

Windows 7 Pro

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

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.

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

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.
My System SpecsSystem Spec

 Bat Script Thingy

Thread Tools

Similar help and support threads
Thread Forum
Windows Script Host: Can not find script file ?
Hello & Thanks , win7 x64 Starting yesterday , I keep getting the following message: Windows Script Host Can not find script file "C:\ProgramData\{95137DD0-C591-AC56-7417-DCD4A4950F5A}\\lare.txt". Any idea why and how to fix it ? Thanks/ ...Vern Tags: win7 x64, Download Games...
General Discussion
Icon selector...thingy?
Hello there, I was wondering is there a way to change it's color from blue to something else? Like green or red etc.
How to install Teredo IPv6 thingy?
Hiya, While troubleshooting, i uninstalled Teredo (it was already disabled). The workaround was demonstrated, but now i don't know how to put it back. I've hunted around and i've found instructions for Vista (and i couldn't comprehend them), but not w7. How do i re-install Teredo? ...
Network & Sharing
What does the red-thingy mean?
Hi again, I wondered what the red thing means... I can click on it and when I do I enter some website which reminds me of Google? Here are two attached files... Can I turn it off? If so, how? It's linked to Seekarium or something like that... How do I get it out of my system? I was...
Browsers & Mail

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:56.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App