View unanswered posts | View active topics It is currently 20 Apr 2014 05:08



Post new topic Reply to topic  [ 5 posts ] 
How do I assign the value of one variable to another variabl 
Author Message

Joined: 24 Apr 2012 19:27
Posts: 2
Post How do I assign the value of one variable to another variabl
Hello all

I'm stuck on a very simple problem to which I have searched all over for an answer. No luck anywhere Googled high and low and searched this forum, all to no avail.

How does one put the value of one variable into another variable?

I have very little experience with batch files so I may be coming at this completely wrong. All corrections and suggestions gratefully accepted.

Here's the problem. I'm writing a script which:

launches Word 2007 with a file name derived from the current date.
The user writes his document then saves it as a PDF file and then exits Word.
Adobe reader is then launched so that he can examine the PDF file. He then exit's Reader.
He is then asked for a password. And then asked to enter the password again. The passwords are compared.
The PDF file is then encrypted using the console version of AES-Crypt.
Script checks for the existence of the encrypted file which will be called filename.pdf.aes and places a copy on the desktop. User can then attach and email.
Script then securely wipes both the Word and PDF file and keeps a copy of the aes file.

There are some options: Does the user want to go back and edit if he spots an error before encrypting? Does he want to save the Word file and come back to it later?

And there is the problem.

If there exists a Word file, he is asked if he would like to edit it. If not it is deleted (don't want multiple files accumulating).

The existing Word file name is put into a variable with this code:
for /F %%a in ('dir /b *.docx') do set xfileName=%%~na
There will never be more than one Word file in that directory.

The file name for a new set of files, Word and PDF, is derived this way:
set mydate=%DATE:~0,2%%DATE:~3,2%%DATE:~8,2%
set filename=PTPL%mydate%

If he starts a new file the file name will be %filename%
The existing file name will be %xfileName%

All the subroutines are set to work with %filename% so surely the simplest thing to do is put the value of %xfileName% into %filename% ?

So I said: set %filename%=%xfileName%

To my astonisment, it doesn't work. How can I do that?

All comment, suggestions and advice gratefully accepted.

Another less pressing problem: How can I mask password entry?

TIA

Harry

Edit:

I think I may have just answered my own question. I suppose I can just declare the %filenme% variable from scratch. Instead of getting its value from %mydate% it will get its value from %xfileName%

Will SET filename=%xfileName% overwrite the original?


24 Apr 2012 20:28
Profile

Joined: 08 Apr 2012 17:11
Posts: 187
Post Re: How do I assign the value of one variable to another var
SET filename=%xfileName% DOES overwrite %filename%. If you want %xfilename% to be part of %filename%, then you should do something like
Code:
set filename=%filename% %xfilename%

or
Code:
set filename=%xfilename% %filename%
.


25 Apr 2012 04:05
Profile WWW

Joined: 10 Feb 2012 02:20
Posts: 3651
Post Re: How do I assign the value of one variable to another var
double post


Last edited by foxidrive on 25 Apr 2012 08:14, edited 1 time in total.



25 Apr 2012 08:12
Profile

Joined: 10 Feb 2012 02:20
Posts: 3651
Post Re: How do I assign the value of one variable to another var
Quote:
So I said: set %filename%=%xfileName%


This will put the value of xfilename into the filename variable.

set filename=%xfileName%


25 Apr 2012 08:13
Profile

Joined: 24 Apr 2012 19:27
Posts: 2
Post Re: How do I assign the value of one variable to another var
Thanks to foxdrive and Fawers for your responses.

That problem is now solved.

Apologies regarding double post, will take my masked password query to the appropriate thread.

Regards.

Harry


25 Apr 2012 10:15
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.