Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
DOS/PDA/Other
Tag Cloud
access audio black screen blue screen boot bsod connection crash desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery registry cleaner router safe mode screen slow sound spyware trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Solved: seeking alteration in batch file

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
22-Oct-2009, 05: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 06:05 AM. Reason: additional data
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,487 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
22-Oct-2009, 02: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 Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
vipulgos's Avatar
Computer Specs
Junior Member with 6 posts.
 
Join Date: Oct 2009
Experience: Intermediate
23-Oct-2009, 03: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 5,487 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
23-Oct-2009, 03: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, 09:04 AM #5
solved thanx 4 ur help sir
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,487 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
23-Oct-2009, 05: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 Bookmark and Share

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:06 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.