0

How can I make copies of some files with a specific extension (but changing the extension) just based on their extension?

I've tried just showing those files but get nothing:

@echo off

for %%f in (*.ext) do(
  echo %%~nf
)
pause

My other option is copy all those and change their extension in a different folder. Any help would be appreciated

1

3 Answers 3

0

In the old DOS days we used this:

@echo off

copy *.{ext} {destination path}\*.{new ext}

Example:

I wanted to copy all of my sketchup files from a Temp Download folder to a Sketchup_Files folder in my User folder.

I created a text file with the command lines:

@echo off

copy *.skp C:\Users\Me\Sketchup_Files\*.txt

I saved this file as a .bat and pasted it into my target folder {Temp Download}

Good Luck.

3
  • Ok but how can I copy those files but with different extension, I mean I just care of many file's names and getting those with different extension May 9, 2015 at 2:10
  • Gotcha, you're question wasn't clear about copying them to a new location with a new file extension. Give me a sec to see what I can remember, there is a command for that. Ok, I've updated my answer for you.
    – OSol1tair3
    May 9, 2015 at 2:57
  • Thanks for the help it works as expected, hope don't mind for identation added May 9, 2015 at 4:54
1

for %f in (*.ext) do copy "%~f" "%~nf - Copy%~xf" will make copies of all files with the specified extension in the same directory with " - Copy" appended just as Windows Explorer does.

If you use it in a batch file remember to double all % signs.

5
  • Thanks @Karan, I've edited my question because I forgot to specify the change of extension I wanted May 13, 2015 at 5:24
  • @CharlesRojas: I don't get it. If you want to make copies of files with the same name in the same directory but a different extension, all you need to use is copy *.ext *.newext. This seems so obvious that I'm unsure whether it's what you want to do or I'm not understanding your requirements properly perhaps.
    – Karan
    May 13, 2015 at 17:25
  • Yes, that was what I wanted, just didn't know and I've trying to check by echoing each file May 14, 2015 at 22:00
  • @CharlesRojas: Oh ok then. Frankly the accepted answer is unnecessarily using two commands when just one will do. I don't know why he's using a separate ren command.
    – Karan
    May 14, 2015 at 22:02
  • You're right, that would be a better option May 14, 2015 at 22:16
0

What's wrong with something like copy *.ext *.ex2 ?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .