move filename bar.filename, without mentioning filename twice?

1

How do I move filename to bar.filename without mentioning filename twice?

In Bash I can just do: mv {,bar.}filename. I suppose I could do:

set filename="foobar" && mv "%filename%" "bar.%filename%"

But that seems overly verbose. Could write a function also, but that seems overkill:

@echo off & setlocal ENABLEEXTENSIONS
set str="%1"
call :move %str%

:move
mv/%1/bar.%1

A T

Posted 2014-12-27T04:49:20.933

Reputation: 641

I'm not a Batch expert, but something looks amiss with your set filename=... line: shouldn't that be set foobar=...? – BenjiWiebe – 2014-12-27T05:10:52.660

I don't know such way in DOS or PowerShell and I doubt it exists. I suggest to install Git, as it includes Bash, which is just wonderful – janos – 2014-12-27T10:21:09.813

No answers