1.

Solve : using wildcard - file name as variable?

Answer»

so I have files and im not sure about the title of what it is, it could be anything from 001.money to 999.money. I want SET to read the file that ends with .money. then after that can I make it so that money=100 instead of money=100.money? heres the code I have so far but not working. Im not sure if ?'s are wildcard in DOS but I also tried with a single *.

Code: [Select]SET money='???'.money
SET skill="???".skill
SET armor="???.armor"
SET life='???.life'
I also had

Code: [Select]SET money='*'.money
SET skill="*".skill
SET armor="*.armor"
SET life='*.life'
im not sure which code i am supposed to use.Quote from: gamerx365 today

I want SET to read the file that ends with .money

Not sure what you mean by "want SET to read the file" but if you just want to RENAME the files..... try:
Code: [Select]@echo off
cls

set money=001
:LOOPING

if exist %money%.money ren %money%.money %money%

set/a money=%money%+1

if %money% gtr 999 goto end

goto looping


:end
not really, i just want the number imported and set as %money% and then eventually I will rename it to %money%+5 or whateverI forgot about the octal problem with set/a so the .bat SCRIPT won't work anyway.

If I understand your goal CORRECTLY, I think you want something LIKE:
Code: [Select]for /f %%a in ('dir *.money /b') do set money=%%~na
echo Money=%money%


Discussion

No Comment Found