?
Solved

Copying files from a server and text processing

Posted on 2014-04-16
3
Medium Priority
?
184 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 57

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 57

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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 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