0

I have this code:

%a% represents a folders name e.g. "TEST123"

for %%a in (*) do rename "%%a" "%%a-%a%"

The function above renames all the files in that folder by appending the file name with the folders name e.g.

FromWater.avi Towater.avi-TEST123

This issue is that I want the ".avi" to be at the end.

Is there a way to get rename to rename but 4 letters in.

Arthor
  • 666
  • 2
  • 13
  • 40

1 Answers1

1

Like this, using the modifiers :

for %%a in (*) do rename "%%a" "%%~na-%a%%%~xa"
SachaDee
  • 9,245
  • 3
  • 23
  • 33
  • 2
    There is various delimiters you can use in a FOR loop. Check `FOR /?`. `%%~na` for just the name, `%%~xa` for the extension, etc... – SachaDee Jun 23 '14 at 18:28
  • 2
    Here is a full list of modifiers if don't have a console near by: http://stackoverflow.com/questions/5034076/what-does-dp0-mean-and-how-does-it-work/5034119#5034119 – Alex Jun 23 '14 at 18:36