Computing.Net > Forums > Disk Operating System > batch - var/loop help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch - var/loop help

Reply to Message Icon

Name: simon
Date: September 2, 2003 at 01:58:37 Pacific
OS: XP Professional
CPU/Ram: 1024 MB
Comment:

Hey,

I need a script to use the following command on all files in a directory:

The script sets all the files in the directory into a variable and applies the following command to all of them (each file individually):

bfish /i:%filename% /o:%filename%_encrypt /p:%password% /e

I know how to set data to variables, however, I'm not sure how to apply a command to all files in a directory simultaneously.

The script will hopefully look something like this:

Directory? enter directory here
Password? enter encryption password here

Script then continues to apply the command to all files in the directory that it has found

Any help MUCH appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: September 2, 2003 at 02:56:40 Pacific
Reply:

The following script should work as you want; it requires Windows NT/2K/XP environments:

@Echo Off
Echo ENCR - Encryption Utility
Set Fldr=
Set Pswd=

:INIT
Echo.
Set /P Fldr=Enter Folder:
If %Fldr%.==. GoTo MSG
If not exist %Fldr%.\Nul GoTo MSG
GoTo EXEC

:MSG
Echo.
Echo Folder [%Fldr%] missing or not found
GoTo INIT

:EXEC
Set /P Pswd=Enter Password:
Echo.
Echo Folder is [%Fldr%]
Echo Encryption Password is [%Pswd%]
Echo.
Echo Press any key to process or Ctrl+C to end
Pause > Nul

For %%I in (%Fldr%.\*.*) Do (
Echo Encripting %%I
bfish /i:%%I /o:%%I_encrypt /p:%Pswd% /e
)
Echo.
Echo Processing completed
Set Fldr=
Set Pswd=

Have a nice day


0

Response Number 2
Name: simon
Date: September 2, 2003 at 03:29:52 Pacific
Reply:

C:\doswork>test
ENCR - Encryption Utility

Enter Folder: c:\doswork\texts
Enter Password: paxbucuuile

Folder is [c:\doswork\texts]
Encryption Password is [paxbucuuile]

Press any key to process or Ctrl+C to end
Encripting c:\doswork\texts.\April 2003.txt
Error: Unable to open the input file
Encripting c:\doswork\texts.\August 2003.txt
Error: Unable to open the input file
Encripting c:\doswork\texts.\July 2003.txt
Error: Unable to open the input file

Processing completed


0

Response Number 3
Name: simon
Date: September 2, 2003 at 03:33:06 Pacific
Reply:

Oh, nevermind, it was because of the spaces in the file names.

Thanks a lot for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: batch - var/loop help

Batch file loop error www.computing.net/answers/dos/batch-file-loop-error/10525.html

batch scripts I NEED HELP www.computing.net/answers/dos/batch-scripts-i-need-help/1772.html

Batch files & looping www.computing.net/answers/dos/batch-files-amp-looping/9628.html