Link to home
Start Free TrialLog in
Avatar of wasabi3689
wasabi3689Flag for United States of America

asked on

how to copy files based on a file to a locaiton

I have a flat file named "Outflatfile.txt, the format like below

ABC|\\rootsql\Documents\rewrerwerwe.doc
cfg|\\rootsql\Documents\rewre234erwe.doc
AGC|\\rootsql\Documents\rewre321rwe.doc
cfK|\\rootsql\Documents\reerewre234ere.doc
.....
etc

Now I want to copy all the file based on the directory specified "\\rootsql\Documents" to a new location, let's \\newhome\documents

How to do that?
Avatar of NVIT
NVIT
Flag of United States of America image

for /f "tokens=1* delims=|" %%a in ('type "Outflatfile.txt"') do (
  copy "%%b" "\\newhome\documents"
  pause
)

Open in new window

Avatar of wasabi3689

ASKER

how to log the copying?
It doesn't work. I have this returned

CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Start Time: Wed 03/15/2017  9:51:06.85
The system cannot find the path specified.
Finish Time: Wed 03/15/2017  9:51:06.88
Press any key to continue . . .

Here is the

for /f "tokens=1* delims=|" %%a in ('type "\\mysql3\Outflatfile.txt"') do (
  copy "%%b" "\\newhome\documents"
  pause
)

Actually,

to read file location is  \\mysql3\Outflatfile.txt
source files from location \\rootsql\Documents\
destination location \\newhome\documents
ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I still have this error

CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Start Time: Wed 03/15/2017 17:13:12.46
The system cannot find the file specified.
Press any key to continue . .

How to troubleshoot that? .
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
Press any key to continue . . .
The system cannot find the file specified.
> How to troubleshoot?
- Review FNLog. It shows the filenames.
- Disable @echo off at line 1. Then run it again.
I see these from log

1 copy "PDF" "\\testsql\NGProduction\NGFinalDocs\Documents2"
1 copy "PDF" "\\testsql\NGProduction\NGFinalDocs\Documents2"
1 copy "PDF" "\\testsql\NGProduction\NGFinalDocs\Documents2"
1 copy "PDF" "\\testsql\NGProduction\NGFinalDocs\Documents2"
1 copy "PDF" "\\testsql\NGProduction\NGFinalDocs\Documents2"

can you tell what went wrong?
I can guess it's having issues with the filenames in Outflatfile.txt.
Post a sample of the lines in Outflatfile.txt
Here is the sample lines

PDF|\\testsql\NGProductionDocs\NGSourceDocs\Documents2\2FD58F4B-57A2-4F88-A3B4-02CD8263B2C8.doc
PDF|\\testsql\NGProductionDocs\NGSourceDocs\Documents2\A7D10A14-9825-4C98-A493-03CD07E77A54.doc
PDF|\\testsql\NGProductionDocs\NGSourceDocs\Documents2\F7AF2932-E9F6-4292-8028-BC617ECF982F.doc
I fix this issue. But, I need help to update your script

So far, I have to press  enter key to copy one by one file to destination folder. How do I avoid the enter key to press when program runs?
Remove the PAUSE on line 15