DosTips.com

A Forum all about DOS Batch
It is currently 04 Dec 2016 02:09

All times are UTC-06:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 24 Apr 2012 20:28 
Offline

Joined: 24 Apr 2012 19:27
Posts: 2
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?


Top
   
PostPosted: 25 Apr 2012 04:05 
Offline

Joined: 08 Apr 2012 17:11
Posts: 187
SET filename=%xfileName% DOES overwrite %filename%. If you want %xfilename% to be part of %filename%, then you should do something like
Code: Select all
set filename=%filename% %xfilename%

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


Top
   
PostPosted: 25 Apr 2012 08:12 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
double post


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

Top
   
PostPosted: 25 Apr 2012 08:13 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 6033
Quote:
So I said: set %filename%=%xfileName%


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

set filename=%xfileName%


Top
   
PostPosted: 25 Apr 2012 10:15 
Offline

Joined: 24 Apr 2012 19:27
Posts: 2
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited