# dos batch rename files with decimal point in the filename



## dnicks (Jul 15, 2011)

i have a batch file to rename folder.jpg in my movie folders to the same name as the movie folder itself. all works just fine, unless i add the IMDB score to the filename like this - The Adjustment Bureau (7.2), then when the batch operation reaches the decimal point in the name it thinks the name is over and just add .jpg to it. So, I end up with The Adjustment Bureau (7.jpg. Is there any way to make the bat file skip this first decimal point?

This is what I'm using.

```
SET folder=%1
SET video=%2
FOR %%a IN ("%cd%") DO SET folderonly=%%~Na
COPY /Y "folder.jpg" "%folderonly%.jpg"
```


----------



## Squashman (Apr 4, 2003)

Of course it will chop off the *.2*. That is how the command modifier you are using works. You are asking for the filename only. So everything after the last period goes bye bye.

I will see what I can figure out for you this weekend. Even if you use the path modifier it gets goofy because of the spaces in the folder name and quotes don't seem to help.


----------



## dnicks (Jul 15, 2011)

i wasn't sure if it was possible or not. thank you for your efforts


----------



## Squashman (Apr 4, 2003)

This was simpler than I thought it would be. Just use the modifier for the file extension as well. When the folder name doesn't have a period in it, the extension will just be null but when there is a period in the folder name the output would be the period with everything after it.

I was totally over thinking the solution to this. Certainly wasn't following the #1 rule: K.I.S.S.

```
C:\Users\Squashman\batch\The Adjustment Bureau (7.2)>FOR %a IN ("%cd%") DO SET folderonly=%~na%~xa

C:\Users\Squashman\batch\The Adjustment Bureau (7.2)>SET folderonly=The Adjustment Bureau (7.2)

C:\Users\Squashman\batch\The Adjustment Bureau (7.2)>echo %folderonly%
The Adjustment Bureau (7.2)

C:\Users\Squashman\batch\The Adjustment Bureau (7.2)>
```


----------



## dnicks (Jul 15, 2011)

wow, hard to believe it was that easy. i still would've never thought of it. Thank you so much!


----------



## Squashman (Apr 4, 2003)

Well you knew enough to use the one file modifier. It was just a matter of looking at the help file to see what all the file modifiers did.


----------

