Reputation: 3
I have roughly 2000 documents in one folder and I want to seperate them into different folders. I have created a "documents.txt", which lists every file I´m interested in.
The .txt file reads as:
C:\Users\NIE\Desktop\test2\one.pdf
C:\Users\NIE\Desktop\test2\two.pdf
C:\Users\NIE\Desktop\test2\three.pdf
So now I went on creating a .bat file:
@echo off
FOR /F "delims=" %a IN (C:\Users\...\Desktop\test2\documents.txt) DO COPY "%%~a" "C:\Users\...\Desktop\test2\kopieren\%%~nxa"
The folder structure is like:
In "...\Desktop\test2", all documents are located. In a subfolder ("...\Desktop\test2\copy"), the specific documents (as listed in the documents.txt) should be copied.
While running my code, I´m getting the statement:
%C:\Users\...\Desktop\test2\one.pdf
The syntax for the filename, path is wrong
0 files were copied.
So I guess the "%" seems to be the bad guy here. I tried different styles for the .txt file, like
one.pdf
userprofile%\Desktop\test2\one.pdf (thought I could use the first % for completing the "%userprofile%" stuff
Every solution I could find via google did not worked either, the formatting of the .txt file seems to be a problem in my case.
Really looking forward for you answers :)
Upvotes: 0
Views: 149
Reputation: 1071
Looks like you have done a fatal mistake: %a
Fixed:
FOR /F "delims=" %%a IN (C:\Users\...\Desktop\test2\documents.txt) DO COPY "%%~a" "C:\Users\...\Desktop\test2\kopieren\%%~nxa"
Upvotes: 1