?
Solved

Copying files from a server and text processing

Posted on 2014-04-16
3
Medium Priority
?
185 Views
Last Modified: 2014-04-18
Hi EEE,


I have a txt file like below. I need to fetch the first value inside [ ]
(only the file name so example0eef817e-fdde-471a-b5d1-1bc627213d51.pdf)  and put them into a text file, file_leftover. Then I need to iterate thru these and copy from the server. It could occur in two paths on the server:

\\123456-PROD\AttachedDocuments\
\\123456-PROD\AttachedDocuments\Set


 How can I do this?

File:

*WARNING* Data file ["F:\Data_Pull_Feb42014\0eef817e-fdde-471a-b5d1-1bc627213d51.pdf"] was not found or subfolder ["DailyVitamin"] not created.
0
Comment
Question by:LuckyLucks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Expert Comment

by:Bill Prew
ID: 40005655
Will there be more than one file name in [] in the text file, and you need to extract them all?

Can you give a more comprehensive example of the text file, showing why you said "I need to fetch the first value". Can there be multiple paths inside the same []?  If so what does that look like?

~bp
0
 

Author Comment

by:LuckyLucks
ID: 40005660
No only one filename ever. So always one full path.

The first value I say because in the line there is a second [] that contains something else and I don't need anything from the second [ ].
0
 
LVL 58

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 40005702
Okay, hopefully I understood what you needed, this seemed to do what you described when I tested it here, give it a try.

@echo off
setlocal EnableDelayedExpansion

set InFile=textfile.txt
set OutFile=file_leftover.txt
set SearchFolders="\\123456-PROD\AttachedDocuments\","\\123456-PROD\AttachedDocuments\Set"
set DestDir=c:\

if exist "%OutFile%" del "%OutFile%"

for /f "tokens=2 delims=[]" %%A in ('findstr /r /c:"[.*]" "%InFile%"') do (
  for %%B in (%SearchFolders%) do (
    if exist "%%~B\%%~nxA" (
      echo %%~B\%%~nxA>>"%OutFile%"
      copy "%%~B\%%~nxA" "%DestDir%"
    )
  )
)

Open in new window

~bp
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question