Hello DosTips
I want to create a batch for my problem.
I have many pictures of people with the filename: name_forename.jpg
Now i wantto rename them to: forename.name.jpg but i can't use "ren" on windows for switching words.
Can someone help me with an example?
Thank you very much...
Regards
Okan Koc
Rename filename - switching words
Moderator: DosItHelp
Re: Rename filename - switching words
Code: Select all
for /F "tokens=1-3 delims=_." %%a in ('dir /B /A-D *_*.jpg') do ren "%%a_%%b.%%c" "%%b.%%a.%%c"
Antonio
Re: Rename filename - switching words
Hi Antonio
Thanks for your fast Response.
But how can I define the path where the pictures are?
In the best situation, i should give a new path where the pictures should be created again with the new name.
Regards
Okan
Thanks for your fast Response.
But how can I define the path where the pictures are?
In the best situation, i should give a new path where the pictures should be created again with the new name.
Regards
Okan
Re: Rename filename - switching words
okan wrote:In the best situation, i should give a new path where the pictures should be created again with the new name.
Did you happen to read the help file for the RENAME command. Read the last line.
Code: Select all
H:\>ren /?
Renames a file or files.
RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.
Note that you cannot specify a new drive or path for your destination file.
You have now changed the parameters of your question which wastes time for the person who helped who now has to go back and change their code.
Before you post anymore question on the forums please read the thread that we have pinned to the top of the forum
How to get help for a batch script - quickly!
Re: Rename filename - switching words
Use MOVE instead of REN if you want to move the files to another directory with a new name.If you rather want to preserve the original files use COPY the same way.
Steffen
Code: Select all
for /F "tokens=1-3 delims=_." %%a in ('dir /B /A-D *_*.jpg') do move "%%a_%%b.%%c" "c:\wherever\%%b.%%a.%%c"
Steffen
Re: Rename filename - switching words
Hello aGerman
I am writing for the first time a script.
I really don't know where i specify the source (the path where my pictures are..).
Can you help me about this problem?
Thanks in forward..
regards okan
I am writing for the first time a script.
I really don't know where i specify the source (the path where my pictures are..).
Can you help me about this problem?
Thanks in forward..
regards okan
Re: Rename filename - switching words
Replace source variable with the correct path and retest.
Code: Select all
set "source=C:\source\directory"
pushd "%source%"
for /F "tokens=1-3 delims=_." %%a in ('dir /B /A-D *_*.jpg') do move "%%a_%%b.%%c" "c:\wherever\%%b.%%a.%%c"
popd
Re: Rename filename - switching words
perfect..
Thank you very mutch..
Thank you very mutch..