Hi,
I don't know how to do this, so please help me.
I have "xyz.jpg" file and I want to copied several times the same .jpg file and rename into x-folder, but name must read from x.txt file.
xyz.jpg must stay unchanged.
xyz.jpg -> c:\x-folder\txt(first line).jpg ... 3865.jpg
xyz.jpg -> c:\x-folder\txt(second line).jpg ... 42578.jpg
xyz.jpg -> c:\x-folder\txt(third line).jpg ... 359871.jpg
xyz.jpg -> c:\x-folder\txt(fourth line).jpg ... 2589.jpg
...
x.txt file
3865
42578
359871
2589
...
copy and rename files
Moderator: DosItHelp
copy and rename files
Last edited by novmar on 20 Oct 2013 10:50, edited 2 times in total.
Re: copy and rename files
use a for /f loop to read the file and a copy command inside the loop.
Re: copy and rename files
tnx for help foxidrive, I made code what I need
For /f %%a in (x.txt) do copy C:\x-folder\xyz.jpg > c:\test\%%a.jpg
For /f %%a in (x.txt) do copy C:\x-folder\xyz.jpg > c:\test\%%a.jpg
Re: copy and rename files
novmar wrote:tnx for help foxidrive, I made code what I need
For /f %%a in (x.txt) do copy C:\x-folder\xyz.jpg > c:\test\%%a.jpg
That will almost work for you, if the > is removed.
For future use and to support long filenames then this is a little more robust:
Code: Select all
For /f "delims=" %%a in (' type "x.txt" ') do copy "C:\x-folder\xyz.jpg" "c:\test\%%a.jpg"
Re: copy and rename files
yes, without > is work
tnx
I have one question +
if I have x.txt with...
date;name-x;12456
date;name-x;1212
data;name-y;1213
data;name-y;57213
data;name-y;125513
data;name-z;11300
and *.jpg file with name
name-x.jpg
name-y.jpg
name-z.jpg
now, I know how set code if I have one .jpg
but how to set a code if i have several .jpg files whitch we have to rename
IF in x.txt name-x = name-x.jpg > copy and rename 12456.jpg
IF in x.txt name-x = name-x.jpg > copy and rename 1212.jpg
IF in x.txt name-y = name-y.jpg > copy and rename 1213.jpg ...
tnx
I have one question +
if I have x.txt with...
date;name-x;12456
date;name-x;1212
data;name-y;1213
data;name-y;57213
data;name-y;125513
data;name-z;11300
and *.jpg file with name
name-x.jpg
name-y.jpg
name-z.jpg
now, I know how set code if I have one .jpg
Code: Select all
For /f "tokens=3 delims=;" %%a in (x.txt) do copy C:\x-folder\name-x.jpg c:\x-folder\Renamed\%%a.jpg
but how to set a code if i have several .jpg files whitch we have to rename
IF in x.txt name-x = name-x.jpg > copy and rename 12456.jpg
IF in x.txt name-x = name-x.jpg > copy and rename 1212.jpg
IF in x.txt name-y = name-y.jpg > copy and rename 1213.jpg ...
Re: copy and rename files
I found one solution and is work
but this code doesn't recognize CRO letters (ščćžđ)
Code: Select all
For /f "tokens=2,3 delims=;" %%a in (x.txt) do copy C:\x-folder\%%a.jpg c:\x-folder\Renamed\%%b.jpg
but this code doesn't recognize CRO letters (ščćžđ)