LuckyLucks
asked on
setting variables for additional processing in batch script
Hi EEE
I have a txt file with the following format:
ServerName\Dir1\file1.pdf newfile1_test.txt newfile1 n
ServerName\Dir2\file2.pdf bestfile2_test.txt bestfile2 b
etc
I want to write a batch script that does the following:
1. Read each line from the text file for a round of processing
1.1 Store each of the four strings of the line into 4 vars - source , destfile, destfolder, destpparentfolder
1.2 Check if destparentfolder exists on the C:/ of server2.If it doesn't, create it.
1.3 Check if destfolder exists under C:/destparentfolder. If it doesn't, create it.
1.4 Put the destfile in the C:/destparentfolder/destfo lder.
I have a txt file with the following format:
ServerName\Dir1\file1.pdf newfile1_test.txt newfile1 n
ServerName\Dir2\file2.pdf bestfile2_test.txt bestfile2 b
etc
I want to write a batch script that does the following:
1. Read each line from the text file for a round of processing
1.1 Store each of the four strings of the line into 4 vars - source , destfile, destfolder, destpparentfolder
1.2 Check if destparentfolder exists on the C:/ of server2.If it doesn't, create it.
1.3 Check if destfolder exists under C:/destparentfolder. If it doesn't, create it.
1.4 Put the destfile in the C:/destparentfolder/destfo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. I think you might get a simpler solution using xcopy or robocopy, since they are capable of creating the destination paths they need.
2. I do not understand the control statements from your posted example and description.
2. I do not understand the control statements from your posted example and description.
ASKER
Bill, How do I get rid of the overwrite and the is the file a file or directory (when no overwrite)?
I figured that the batch file part was the hard part, and that you'd know how to use the COPY command. The help screen for the COPY command comes in handy here:
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY command is being executed from within a batch script.
So, add the "/Y" switch after "COPY" to avoid the prompt. You can also use XCOPY, RoboCopy, or a host of other command-line copy tools. See each tool's specific command line options for properly using it.
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY command is being executed from within a batch script.
So, add the "/Y" switch after "COPY" to avoid the prompt. You can also use XCOPY, RoboCopy, or a host of other command-line copy tools. See each tool's specific command line options for properly using it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all.
ASKER
With a /Y I still get - Does C:\a\abc\abcfile1.pdf specify a file name or directory name on the target <F=file, D=directory>?
Switch to XCOPY, and thay should go away.
ASKER