Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory monitor motherboard music network printer problem ram registry router server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Solved: seeking alteration in batch file

Reply  
Thread Tools
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
22-Oct-2009, 06:59 AM #1
Solved: seeking alteration in batch file
dear all,
I have a batch file as under:

@echo off
"C:\Program Files\WinZip\WINZIP32.EXE" -min -a -ex "C:\Documents and Settings\vipul\Desktop\vipul.zip" files vipul.xls
copy vipul.zip "C:\Documents and Settings\vipul\Desktop\My briefcase"
copy vipul.zip "E:\Valuations\2009"
exit
HERE vipul.xls is the fileon my desktop which is to be copied to my broefcase and same is to be ziiped and then sent to E\valu...folder.
Alteration i want here is as under:
every time the file name is getting changed, e.g. it may be sanj.xls or lago.xls and so on. (in place of vipul.xls), so how i can do this?
Just like there is printdir.bat file in xp

Last edited by vipulgos; 22-Oct-2009 at 07:05 AM.. Reason: additional data
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
22-Oct-2009, 03:34 PM #2
Your batch file will add two files to the archive, one named vipul.xls and one named files.
I'm assuming that files doesn't need to be there; in the syntax examples, files is used to show where to put the file name you want to work with, it's not actually part of the command.
So that line should be this:
Code:
"C:\Program Files\WinZip\WINZIP32.EXE" -min -a -ex "C:\Documents and Settings\vipul\Desktop\vipul.zip" vipul.xls
If the file name changes, you would have to modify the batch file if you want to run the batch file directly. You can set it up to allow you to drag and drop the file onto the batch file (or a shortcut to it), or specify the file name on the command line.
The following will work in any user account. I've also set it up so you can specify the Valuations folder path in the 2nd line. This will let you easily change it to a different drive, or for next year. It will also create the Valuations and Briefcase folders if needed.
Code:
@Echo Off
Set _Valuations=E:\Valuations\2009
If Not [%1]==[] Goto _ChkIt
If EXIST "%Temp%\Tmp.txt" Del /F "%Temp%\Tmp.txt"
:_Error
>>"%Temp%\Tmp.txt" Echo.You must specify a file name, either on the command line, or
>>"%Temp%\Tmp.txt" Echo.by dropping the file you wish moved to the Briefcase onto the icon.
>>"%Temp%\Tmp.txt" Echo.Close this window to exit.
Start /W "" Notepad "%Temp%\Tmp.txt"
Del /F "%Temp%\Tmp.txt"
Goto :EOF
:_ChkIt
If EXIST "%~1" Goto _ZipIt
>"%Temp%\Tmp.txt" Echo.Unable to locate "%~1"
Goto _Error
:_ZipIt
Set _ZipName=%~n1.zip
If NOT EXIST "%UserProfile%\Desktop\My Briefcase" MD "%UserProfile%\Desktop\My Briefcase"
If NOT EXIST "%_Valuations%" MD "%_Valuations%"
"%ProgramFiles%\Utilities\WinZip\WINZIP32.EXE" -min -a -ex "%UserProfile%\Desktop\%_ZipName%" "%~1"
Copy "%UserProfile%\Desktop\%_ZipName%" "%UserProfile%\Desktop\My Briefcase"
Copy "%UserProfile%\Desktop\%_ZipName%" "%_Valuations%"
HTH

Jerry
__________________
Microsoft MVP - Windows Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
23-Oct-2009, 04:36 AM #3
o.k. working fine. only help needed as under:
I have changed my mind to copy the file on desktop as it is to my briefcase. i.e. i want to send the same file as it is directly to briefcase without zipping and after zipping it should go to valuation folder
only rectification needed is at this line:
Copy "%UserProfile%\Desktop\%_ZipName%" "%UserProfile%\Desktop\My Briefcase"
here _zipname should be like %1. I have tried this but getting failed is it like "%1" or ""%1" or like that?
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
23-Oct-2009, 04:47 AM #4
Replace %_ZipName% with %~1:
Code:
Copy "%UserProfile%\Desktop\%~1" "%UserProfile%\Desktop\My Briefcase"
The Tilde is needed to remove the quotes added when the file is dropped. Otherwise Copy can't properly read the command line.
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
23-Oct-2009, 10:04 AM #5
solved thanx 4 ur help sir
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
23-Oct-2009, 06:36 PM #6
You're Welcome!

If your issue has been resolved you (and ONLY you) can mark this thread Solved by using the Mark Solved button at the Top Left of this thread (above the first post)



Jerry
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:06 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.