1

This is the script I can run from the commandline:

(for /r %i in (*) do @echo %~fsi) | clip

But inside a batch file, I get a syntax error about unexpected brackets....

) was unexpected at this time.

(for /r ~fsi) | clip
| improve this question | | | | |
2

Try this in batch:

@Echo Off
(for /r %%i in (*) do echo %%~fsi) | clip

You must double-up % signs on running in batch files.

| improve this answer | | | | |
  • 2
    "You must double-up % signs on running in batch files.". The key point. – Michael Harvey Feb 1 at 11:12
  • 2
    Use FOR /? to get a helpful short manual, it explains this %% usage and a whole number of other useful tricks FOR can do. – Tonny Feb 1 at 11:28
  • Great, thanks :) – cmaughan Feb 1 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.