VOGONS


First post, by James2000

User metadata
Rank Newbie
Rank
Newbie

Hi All,

The following rename command works from the DOSBox 0.74 command prompt, but it does not appear to work from inside a batch file running on DOSBox 0.74 :-

ren FILEBR~2.JAR TEMP.JAR

Please can you advise if there is a way to get this working (other than to copy and then del source) ?

Thank you for your time,
Best regards,
James

Reply 1 of 4, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Are you sure the line is being executed ?

(as lately I got an email asking why

hello.bat
echo "hi"

(didn't work, it should be call hello.bat inside the bat file)

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 4, by James2000

User metadata
Rank Newbie
Rank
Newbie

Hi Qbix,

Yes it's being executed. I've tested it in a one-line batch file. But it's actually no problem for me to "copy FILEBR~2.JAR TEMP.JAR" and then "if exist TEMP.JAR del FILEBR~2.JAR". So I can just do that. 😀

For your information, I'm running DOSBox 0.74 on Windows 7 Professional (64 bit / version 6.1.7601) and FILEBR~2.JAR full name under Windows is "FileBrowser1.jar".

Cheers,
James

Reply 3 of 4, by SKARDAVNELNATE

User metadata
Rank Oldbie
Rank
Oldbie

The ~2 part indicates it's the second occurrence of that shortened file name. Have you tried it it with ~1?

Reply 4 of 4, by James2000

User metadata
Rank Newbie
Rank
Newbie

Hi SKARDAVNELNATE,

The rename doesn't work with ~1 either. But it is easy to workround using copy and delete. See example batch file ("TEST.BAT") and output produced.

Cheers,
James

@echo off
echo ----All files before rename---->TEST.OUT
dir /b>>TEST.OUT
echo ----ABC files before rename---->>TEST.OUT
dir /b *.ABC>>TEST.OUT

REM Rename fails silently
ren LONGFI~1.ABC XXXXXX.ABC >>TEST.OUT

echo ----All files after rename---->>TEST.OUT
dir /b>>TEST.OUT
echo ----ABC files after rename---->>TEST.OUT
dir /b *.ABC>>TEST.OUT

REM Copy and delete both succeed
copy LONGFI~1.ABC YYYYYY.ABC >>TEST.OUT
del LONGFI~1.ABC >>TEST.OUT

echo ----All files after copy and delete---->>TEST.OUT
dir /b>>TEST.OUT
echo ----ABC files after copy and delete---->>TEST.OUT
dir /b *.ABC>>TEST.OUT
----All files before rename----
LONGFI~1.ABC
TEST.BAT
TEST.OUT
----ABC files before rename----
LONGFI~1.ABC
----All files after rename----
LONGFI~1.ABC
TEST.BAT
TEST.OUT
----ABC files after rename----
LONGFI~1.ABC
LONGFI~1.ABC
1 File(s) copied.
----All files after copy and delete----
TEST.BAT
TEST.OUT
YYYYYY.ABC
----ABC files after copy and delete----
YYYYYY.ABC