MrFregg
MrFregg

Reputation: 216

What does omitting a period after an asterisk do when renaming any file of an extension?

I created a batch file to create a new blank javascript but made a mistake by not adding a period after the asterisks:

@echo off
break>"%~dp0\new.txt"
ren *txt *js

The result was a file labelled new.txtjs. What exactly did my rename command do when I omitted the period?

Upvotes: 1

Views: 39

Answers (1)

woxxom
woxxom

Reputation: 73836

ren command isn't a "string replace" function.

The period in the new file name anchors the position of the following text to the extension, which is everything after the last period, and thus the extension would be replaced with the provided text.

Omitting the period makes * in *js consume all characters of the name and then append js.

Upvotes: 3

Related Questions