I have a folder that contains countless image files. ( jpg, and psd), and one text file "Placehold.txt" ( this text file contains specific instructions inside)
I'm in need of a batch script that will duplicate the Placehold.txt file and rename it to match all image files within this folder. Z:\Images\Converted\
An example of a before and after would look like this:
Cat_001.00_R R.jpg
Dog 3_04 25.00.A.jpg
House_23.00_A DD.psd
Cat_001.00_R R.txt
Dog 3_04 25.00.A.txt
House_23.00_A DD.txt
** each new text file are a copy of the original "Placehold.txt" file
Thanks for any help!
Batch script to rename text files to match image files names.
Moderator: DosItHelp
Re: Batch script to rename text files to match image files names.
This might help you (untested):
penpen
Edit: Corrected critical error, thanks to Squashman for seeing that.
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
pushd "Z:\Images\Converted\"
for %%a in (*.jpg *.psd) do copy "Placehold.txt" "%%~na.txt"
popd
goto :eof
Edit: Corrected critical error, thanks to Squashman for seeing that.
Re: Batch script to rename text files to match image files names.
Thanks, penpen.
But couldn't get this to work.
Any ideas?
Thanks!
But couldn't get this to work.
Any ideas?
Thanks!
Re: Batch script to rename text files to match image files names.
You can try switching
to
Or try adding .txt After %%~a
Code: Select all
for %%a in (*.jpg *.psd) do copy "Placehold.txt" "%%~a"
Code: Select all
for %%a in (*.jpg *.psd) do type Placehold.txt > "%%~a"
Re: Batch script to rename text files to match image files names.
Type would be slower. You just need to use the command modifiers to get the base file name and then add the txt extension.
copy "Placehold.txt" "%%~na.txt"
copy "Placehold.txt" "%%~na.txt"
Re: Batch script to rename text files to match image files names.
I am so sorry for making the above error and want to apologize.
I hope the /Y command wasn't preset in the COPYCMD variable,
so your test environment wasn't messed up.
Thanks to Squashman, for finding that error, i literally didn't see that.
I fixed the above code.
I hope the /Y command wasn't preset in the COPYCMD variable,
so your test environment wasn't messed up.
Thanks to Squashman, for finding that error, i literally didn't see that.
I fixed the above code.